I don't know why but the discount amount varies 1cent when reviewing order. This causes an error the first time. Second time confirming the order helps.

In my case I am testing a discount of 15% off. I tested with a total amount of 169,90, so 15% of it is 25,485. Sometimes the discount routines returns 25,48 and sometimes 25,49 (what it should be). Because they don't match when reviewing the order (cart/checkout/review) an error is displayed: 'Discounts have changed. Please review your cart and continue checkout.'. Matching is based on the discounted values, with an array_intersect on line 2055 of uc_discounts.module($discount_intersection = array_intersect($existing_discount_amounts, $new_discount_amounts));

CommentFileSizeAuthor
#1 uc_discount_alt-1329012.patch640 bytesrobbertnl

Comments

robbertnl’s picture

StatusFileSize
new640 bytes

There seems to be a problem with the discount amount ($discount->amount). The value is always the same (in my testcase with checking out the same product and quantity every time), when displaying the amount before the round function. I don't know why but when casting this discount amount to a string and after that a floatval of that string helps. I also tried using the uc_currency_format function instead of the round function. That also results in inconsistent rounding (same compared to round).

I know my patch is ugly but it seems to work. Maybe someone can figure out what the real problem is here?

robbertnl’s picture

Status: Active » Needs review