• Resolved sandras21

    (@sandras21)


    Hello!
    I′m setting up a new shop and realised while testing that there are mistakes in the calculation if I add more then 1 product to the cart. Prices include vat, vat calculation seems to be correct in the cart but for example if the product price is 4,65, without vat (20%) it will be 3,88 and it displays it in the order. Now if I decide to take 2 items , it becomes 2×3,88 =7,76 but woocommerce is getting 7,75. Similar way 2×5,44 becomes 10,43 not 10,44.otherwise it would not be a big deal but as we sync data with accounting it would make a mess there.
    What shall I do, to get calculation correct?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Senff – a11n

    (@senff)

    Hey @sandras21

    This appears to be a rounding issue. Can you change the setting for Rounding (under WooCommerce → Settings → Tax) and see if that makes a difference?


    Image link: https://d.pr/i/W0tFCw

    Thread Starter sandras21

    (@sandras21)

    I tried it both way, rounding activated there and without, result is same, 2×3,88=7,75 not 7,76. decimal places is set 2. VAT amount is correct.

    I got the first case to work by entering the price as £3.88 and setting “No, I will enter prices exclusive of tax”.

    For 2 @ £5.44, I’m getting £10.88 + £2.18 tax @ 20%, again with prices entered exclusive of tax.

    Thread Starter sandras21

    (@sandras21)

    If I look from orders it looks that woocommerce is still calculating prices 4 decimals, for example:
    6,26 – the price without vat is 5,2166 (if calculating based on 4decimals) and in case of 3 items the sum will be 15,65 (or 15,6499 in case of 4 decimals)
    if rounded to 2 decimals as 5,22 the sum will be 15,66 (bookkeeping)
    In the currency settings I have set it to 2 decimals but seems that calculations are still based on 4 and no rounding applied.
    We need to display prices with vat, so vat excluded version is also not a solution unfortunately.
    Is there any snippets or workarounds to create that rounding?
    https://d.pr/free/i/qhQvVc

    We need to display prices with vat, so vat excluded version is also not a solution unfortunately.

    Its possible to enter prices excluding VAT and use the separate settings on the tax sub-page to display prices in the shop including tax and on the cart and checkout pages including tax.

    I used the below snippet for a particular case, so it may not be suitable for you but I offer it as a starting point. It adds 1 to tthe total, then rounds.

    add_filter( 'woocommerce_calculated_total', 'custom_calculated_total' );
    function custom_calculated_total( $total ) {
      $total = round( $total, 1 );
      return $total;
    }
    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Howdy.

    We haven’t heard back from you in a while, so I’m going to go ahead and mark this thread as resolved. If you have any other questions please start a new thread.

    Cheers!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Calculation problem if more then 1 product in cart’ is closed to new replies.