Hi there!

Thanks for this great module.

I have a Drupal 6.20 / Ubercart 2.x + Marketplace site.

For the first time, I had a user create a CD product at a reduced rate than any of my other users.

I had set: "Show Sell Price field & Use default value below" to R125.

The user entered R90 but when they saved, it used the default price of R125. As administrator, I tried to enter R90 and save, but , the price remained at R125.

Does this entry above, mean that it will always be set to this default price and not be editable? The reason I wanted to show them this price, to start was because I wanted them to see that as a the "recommended price".

Thanks

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

manuel_mra’s picture

Version: 6.x-1.12 » 6.x-1.x-dev
FileSize
164.72 KB
183.39 KB

I have the same problem. I have choosed both : Show Sell Price field on product entry form and Show Sell Price field & Use default value below and it doesn't allow me to change that price.
Can you fix it.
Thanks.

Manuel.

manuel_mra’s picture

Hi:
I have found the cause. It was my error. I have a block that hided that fields.

Manuel.

mail@victorquinn.com’s picture

FileSize
957 bytes

This is a bug, looks like the developers of this module incorrectly used the Drupal Forms API.

When the "Show Sell Price field & Use default value below" option is set, this hits line 140 in uc_product_power_tools.module:

$form['base']['prices']['sell_price']['#value'] = $class_settings['sp_settings'];

Problem is, with the Drupal Forms API, if you set #value, it will ignore any input value from the user thereby making it impossible to change the product price. This should be changed to the following:

$form['base']['prices']['sell_price']['#default_value'] = $class_settings['sp_settings'];

or better:

if ($class_settings['sp_settings'] && !$form['base']['prices']['sell_price']['#default_value']) {
  $form['base']['prices']['sell_price']['#default_value'] = $class_settings['sp_settings'];
}

That will set the default value if the price has not already been set on a product. To show the end result we have the following:

// Handle Sell Price field.                                                                                                                     
    switch ($class_settings['sp']) {
        case 1:
            $form['base']['prices']['sell_price'] = array(
                    '#type'  => 'hidden',
                    '#value' => $class_settings['sp_settings'],
            );
            break;
        case 2:
            if ($class_settings['sp_settings'] && !$form['base']['prices']['sell_price']['#default_value']) {
              $form['base']['prices']['sell_price']['#default_value'] = $class_settings['sp_settings'];
            }
            break;
        default:
            if ($class_settings['sp_settings'] && !$form['base']['prices']['sell_price']['#default_value']) {
              $form['base']['prices']['sell_price']['#default_value'] = $class_settings['sp_settings'];
            }
            break;
    }

Patch is attached.

scotwith1t’s picture

Status: Active » Reviewed & tested by the community

good catch, victorquinn! i can confirm this patch works and i struggle with this every time i install this module and forget about this glitch. you logic about #value and #default_value makes perfect sense too. hopefully this can be committed soon.

eventfarm’s picture

This is also an issue in 7.x-1.x-dev. Will this patch be committed at some point?

thanks!

alb’s picture

the same patch also for the sell_price and cost;
is sufficient copy the default code;

regards default I posted that isn't necessary to have http://drupal.org/node/1876544

stefan.r’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Committed to 6.x-2.x

  • stefan.r committed eae1c2c on 6.x-2.x
    Issue #1046038 by victorquinn: Unable to change Sell Price when "Show...

  • stefan.r committed 4c4ccfe on 7.x-1.x
    Issue #1046038 by victorquinn: Unable to change Sell Price when "Show...
stefan.r’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev

Ported to 7.x

  • stefan.r committed 1f0c7cd on 6.x-1.x
    Issue #1046038 by victorquinn: Unable to change Sell Price when "Show...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

scotwith1t’s picture

Great news! Thanks stefan.r! I've never gotten around to making the switch to Commerce, and this tool was one of my faves for UC. Thanks again! Can't wait to check it out!