Support » Plugin: Order Minimum/Maximum Amount for WooCommerce » 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 to alg_wc_oma_amount_cart_total filter, but I believe this should be fixed in the plugin.

    Cheers,
    Česlav

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Zohaib

    (@zohaibayub85)

    Hi,

    Unfortunately, I am unable to reproduce the error on our end. Can you please make sure you are using the latest version of the plugin and let me know if the error persists.

    Just one question, did you use the Amount types as Sum, and Did you set a sum for all products or did you use the Per product option?

    In the mean time, I have forwarded your request to our development team, they will take a look at it also and get back to you soon.

    Thread Starter Česlav Przywara

    (@chesio)

    Hi,

    I updated to version 4.0.8, but the problem is still there.

    I also have reproduced the problem on a fresh WordPress (5.8.2) and WooCommerce (5.9) installation with only the plugin (in version 4.0.8) active.

    Just one question, did you use the Amount types as Sum, and Did you set a sum for all products or did you use the Per product option?

    Yes, I use the Amount types as Sum. I don’t have the Pro version, so the option “per product” is not available to me.

    The steps to reproduce are as described above. The numbers are important – the product price has to be 20 including 20% tax, so the price without tax is 16.666… and the tax is 3.333… That way the sum of the price without tax and the tax is strictly less than 20 (unless rounded).

    Plugin Support Zohaib

    (@zohaibayub85)

    Hi,

    I am closing this ticket as you already contacted us on our website and we sent you a modified version of the plugin.

    Thread Starter Česlav Przywara

    (@chesio)

    Hi @zohaibayub85,

    that must have been someone else having the same problem… 🙂

    Anyway, I used a filter to fix the problem on my website (as described in my first post), so I don’t need any modified version of the plugin. Just wanted to let you know about the problem.

    Cheers,
    Česlav

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.