0
votes

The cart show wrong calculation when the subscription is for 12 months but is correct when it's 1 month.

Woocommerce settings :

  • Prices enter excluding VAT
  • Calculate Tax Based On : Customer billing address
  • Display prices during cart/checkout : excluding VAT

Do I miss something ?

Screenshot for 1 month subscription

1 month is ok

Screenshot for 12 12 months have wrong total

1
Sorry but it is a bit confussing... one is applying a price of 29.00 and the other one is applying a price of 24.17... there is no way you can match one and the other one. What is it the TAX % you are applying? I assume you are applying a 20% VAT (as far as i knew France was 19.6% anyway) so if that is the case, it is calculating it correctly. Is the pricxe or the total price what is messing it up. So, it seems that the price given in the 12 months is adding the TAX on top of if, and it is adding taxes again. Check the config for the 12 months man, something is wrong configuredAndres Molina Perez-Tome
the base price is 29 for the 12 months I there are 2 month free ( 29 *10 /12 = 24.17) . Now France have VAT 20% no more 19.6%.Core972
I dont understand your calculation above, but in any case, the problem you are facing, is that it is applying the TAXES twice for the 12 month product: (24,17 *12)*1,2 = 348,04 And now if you multiply AGAIN by 1,2 (to apply the taxes again, you get the following 348,04 * 1,2 = 417,60. By this I mean, you need to check the 12 months subscription config as it is aplying TAXES twiceAndres Molina Perez-Tome
By the way I read again your meswsage and i understand the calculation. But is still being same, the 1 month subscription just applies taxes once and the 12 month subscription applies is twiceAndres Molina Perez-Tome
I will try to find where the taxes are applied and find what is the problemCore972

1 Answers

0
votes

The error wasn't the tax calculation but the price itself. When adding 12 months I only changed the price displayed not calculated so I added this function to fix that.

add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );

function add_custom_price( $cart_object ) {

    foreach ( $cart_object->cart_contents as $value ) {
        if ( $value['quantity'] == 12 ) {
            if ( $value['product_id'] == 2244 ) { // Small
                $value['data']->price = 24.16666;
            }
            // Add others products here. Hope there are not many products 
        }
    }
}