Support » Plugin: WooCommerce » Woocommerce Rounding Issue With Tax

  • Resolved piskui07


    my setup is latest Woocommerce+Wordpress+WPML.
    My products is inserted without taxes and relative Woocommerce settings is set correct.
    Playing with “Round tax at subtotal level, instead of rounding per line” settings didn’t help.
    Tax rate is different for each EU country.
    Decimal is set to 2.

    Step to reproduce:
    1) set a product price to 9.19€ (vat excl.)
    2) emulate a purchase in a country with a VAT of 7% and put 3 items of the product in the cart

    This is what happens:
    Woocommerce “internally” compute the cart line: 9.19€+7%(VAT) = 9,8333€ x 3 = 29,4999€ ====> then Woocommerce round subtotal to 29.50€ and display to the user.

    But… the user in the cart see this: 9.83€ (price displayed to user with 7% VAT).

    So for the user 9.83€ x 3 = 29,49€ and not 29.50€!!!!

    How can I fix this?

    I know is only 1 cent but this cause problems with customers and also with our external invoice system (that use the same line of the user 9.83€ x 3 = 29,49€).

    Look forward your response.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Mirko P.


    Hi @piskui07,

    Thanks for reaching out to us!

    The actual tax calculation for WooCommerce does not round each line tax, WooCommerce does instead calculate tax for the invoice line as a whole.

    There has been some discussion already about the 0,01 price difference and you can have a look at this Github thread:

    If you will increase the number of decimals to 4 you will see that the actual product price is not $9.83 but $9.8333 and the totals are $29.4999. This may work for you if you think that the 0,01 price difference may confuse customers.

    Link to image:

    However, as Mike suggested on that thread, to avoid these types of rounding issues you can use tax-exclusive prices. Calculations are more straightforward when prices are exclusive of tax.

    Link to image:

    Hope this all makes sense.

    Thank you.

    Thread Starter piskui07


    thanks for your reply.

    I see with 4 decimal numbers all seems good but this is not a solution since for final customer is not good to see 4 digits decimals… let’s say is not “standard” or common way to display numbers. So this is not a solution for my shop (and I think also for other shops).

    I see the issue is reported from several ecommerce and also that it seems a “very old question”. Also searching in Google I don’t find any (up to date) applicable solution.
    The Git discussion you pointed me is about 2017.
    In the meanwhile there is no update in this topic?
    No one has found a fix or a workaround to apply?
    I tried this workaround but code seems to be old compared to the newest Woocommerce so I don’t know if it is ok.
    By the way, it doesn’t fix my issue, but the base idea under the code I think is good. Basically it force the rounding precision to the same value set in the backoffice settings of WP admin. So if decimal numbers to display to user is 2 also math operation is done with this precision. I udnerstand that this can be a workaround but for some shop can be a good solution and, from my point of view, I’d like to give a try.
    So… Is there a way to set newest Woocommerce version to do math operation using only 2 decimal precision number and not 4 decimal as it do now?

    Plugin Support Adam a11n


    I think a simpler method to do this might be to just set the prices to be entered with taxes included, like this:

    Then, if you have a $9.83 product x 3, you get the amount you expect in the cart and checkout:

    Would that work for you?

    Thread Starter piskui07


    Hi Adam,
    I already tried set all price including tax but this is not a solution.
    Yes… maybe it fix this single test case example but the store has several other products with several different prices and the use case is always valid.

    With price set with tax included the issue is the same when a user from a country not equal to the one of my store try to buy.
    Woocommerce, simplyfing, first remove the VAT in the country of the store and then add the VAT of the country of the user.
    So, dipending on the start price, this is resulting again in 1 cent different on some products cart lines.

    So, again, my question is: Is there a way to set newest Woocommerce version to do math operation using only 2 decimal precision number and not 4 decimal as it do now?

    Plugin Support Shaun Kuschel a11n


    Automattic Happiness Engineer

    Hey @piskui07,

    So, again, my question is: Is there a way to set newest Woocommerce version to do math operation using only 2 decimal precision number and not 4 decimal as it do now?

    There isn’t a solution for this in core WooCommerce at the moment, however, some users have found workarounds for different situations that might be helpful in your case. For example, this open Github issue includes a comment with a code snippet that looks like it limits the number of decimal places used in calculations on the Cart and Checkout pages to “2”, rather than only displaying “2” decimals like WooCommerce does currently:

    Thread Starter piskui07


    Hi @shaunkuschel,
    the piece of code you point me change the decimals diplayed to the user, not the decimals used by Woocommerce to do Math operations. So it is not a solution for me.

    Any other ideas/suggestion?

    Plugin Support Con a11n


    Automattic Happiness Engineer

    Howdy again,

    You will need to use custom code to achieve the rounding for orders / checkout as well. Here is 1 suggestions: and a general approach:

    Please note that we provide no warranty or support for custom code or 3rd party plugins (meaning we cannot not help you further with this code snippet or / GitHub plugins). Use them at your own risk.

    **Also: Before you do that, please do make a full backup!**

    Kind regards,

    Plugin Support maykato


    Hi @piskui07

    We’ve not heard back from you in a while, so I’m marking this thread as resolved. If you have further questions, please feel free to open a new topic.

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