Right after we updated the Ubercart module to 2.10, our product kit module did strange things. First, if you add one item to the kit and save, the total price stays the same. If you change the total price manually, you get an appropriate number added or subtracted to/from the price of the one item showing on the "edit" page.

If you add another item to the kit, not only does the product kit "total price" change on its own but the +/- amount starts changing drastically with every save of the item.

Example:

Product A price = $5.00
Product B price = $1.00

When product B is added to the kit, the total price changes on it's own to $15.00. The product A price gets an offset (discount) of $+7.50. The product B price gets an offset of $+$1.50.

If you click SAVE again, the total price changes to $45.00. The product A offset changes to $+32.50 and product B changes to $+6.50.

I think this is a script problem vs a database problem.

Please advise.

Comments

stg11’s picture

I'm having the same problem. My discounted $16.00 product comes out $18.67. I had to change the input price to $13.71 to get it to come out to $16.00.

stg11’s picture

Category: support » bug

This looks like a bug to me so I'm changing support request to a bug report.
In the above comment I had to change the price to $19.00 and no matter what I put in I couldn't get it to that round number. Please help resolve this issue. Everything worked fine on the prior release.

omih85’s picture

subscribing

Rainman’s picture

Also experiencing this issue, specifically setting total price lower than individual item totals does not take and results in unexpected price increase over original price.

rjlang’s picture

This is a bug in uc_product_kit.module. The value of $base_price (undiscounted price total) is being improperly computed, which then throws off the discount calculation.

You can patch it with the following. Beginning at line 240 of uc_product_kit.module, replace the lines

    foreach ($node->items as $item) {
      $base_price += $product->sell_price * $item['qty'];
    }

with

    foreach ($node->items as $nid => $item) {
      $product = node_load($nid, NULL, TRUE);
      $base_price += $product->sell_price * $item['qty'];
    }

That's not the most efficient fix (because each product object may now be loaded twice), but it's simple and works.

Robert

longwave’s picture

Status: Active » Fixed

This code was changed in #1387638: Product discount & qty blanked when product in kit is updated but was faulty. Thanks for posting the fix, I've committed it to solve this issue. The code in uc_product_kit_update() is pretty ugly and really needs a rewrite, but that can be done some other time; preferably with tests to prove that kits with total prices, discounts, etc. are all proven to work correctly.

dpatte’s picture

The fix in #5 did not work for me, unfortunately.

longwave’s picture

Status: Fixed » Postponed (maintainer needs more info)

Can you give an example of how you have a product kit set up, with details of all prices and discounts involved, what you see, and what you expect to see?

longwave’s picture

Status: Postponed (maintainer needs more info) » Fixed

If I revert the fix in #5 and run the new tests added in #1840260: Add product kit tests they fail, showing that the fix in #5 was correct. I also can't reproduce any discount problems manually.

@dpatte: If this is still an issue for you, please ensure you are running 6.x-2.x-dev, and give full details of the product kit that has incorrect pricing.

dpatte’s picture

Sorry for the delay. I applied the fix manually to ubercart 2.10, not dev.

DanZ’s picture

In #6, he says that he committed the fix. That means that it is already in the -dev release. To get this fix, install 6.x-2.x-dev. Do not apply a patch.

dpatte’s picture

I just installed the latest dev, and this seems to resolve my issue. Thanks guys!

Status: Fixed » Closed (fixed)

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