Bug due to missing rounding of total amounts
-
Hello,
as there is no rounding applied when calculating cart total amount for comparison with the configured min/max values, the plugin can under certain scenarios produce weird notices like this: “You must have an order with a minimum of €20 to place your order, your order current value is €20.” ??
How to reproduce:
1. Enable tax rates and calculations in WooCommerce.
2. Activate “Yes, I will enter prices inclusive of tax” setting.
3. Add a product with price of 20 EUR and tax rate 20%.
4. Set minimum order amount to be 20 EUR and to be calculated on basis of order subtotal. Do not exclude taxes.
5. Place one product with price of 20 EUR in the cart – observe the weird notice mentioned above.The problem: With the single cart item, the order has subtotal (without tax) calculated as 16.666666 and tax as 3.333333. The plugin adds both values together which results in total amount of 19.999999. This value is strictly lesser than 20, therefore the notice is displayed, although the actual subtotal is 20.
The (possible) fix: Apply
wc_round_tax_total
to the (sub)total amount. I don’t know if this is the best way to fix the issue, but it works fine in my case. I fixed the problem by simply hooking this function toalg_wc_oma_amount_cart_total
filter, but I believe this should be fixed in the plugin.Cheers,
?eslav
- The topic ‘Bug due to missing rounding of total amounts’ is closed to new replies.