New Zenner
- Join Date:
- Jun 2013
- Location:
- United Kingdom
- Posts:
- 42
- Plugin Contributions:
- 4
Post #1 by rocketsites
I’m seeing a one-cent discrepancy in the shopping cart when a percentage discount is applied through SaleMaker.
Steps to reproduce
1. Use USD as the default currency, with an exchange rate of 1.00000000 and two decimal places.
2. Set a product's base price to $4.49.
3. Apply a 20% SaleMaker discount to the product's category.
4. Add three of the product to the cart with prices displayed excluding tax.
Actual result
The cart shows $3.59 each and a line total of $10.78
Expected result
The line total should match the displayed unit price × quantity. Three units at $3.59 should total $10.77
Cause and proposed fix
SaleMaker returns $3.5920 as the discounted unit price. The cart displays that as $3.59 but multiplies the unrounded value by three, giving $10.776, which displays as $10.78
The proposed fix for the USD store in question is to round the resulting sale unit price to two decimal places in case 1 of zen_get_products_special_price() in includes/functions/functions_prices.php. That would apply to both the regular-price and special-price calculations in the percentage discount branch. For a core fix, the precision could come from the store's base currency.
Has there been any consideration of rounding the percentage-discounted unit price at this point so the cart line total agrees with the price shown to the customer?