Search code examples
phpwordpresswoocommerceshipping-method

Woocommerce shipping taxes and bad total calculations


Currently the tax total is based only on the sub total and not including the shipping

product $129

cart total $129

shipping $35

sub total $164

tax(10%) should be $16.40 but instead its $12.90

total $176.90 should be $180.40

enter image description here

As you can see I renamed the "sub total" to "Cart total"

and added a "sub total" after the shipping using this code inside the cart-totals.php and review-order.php templates

<tr class="cart-subtotal">
    <th><?php printf( __( 'Sub Total %s', 'woocommerce' ), '' );?></th>
    <td><?php echo wc_price( WC()->cart->get_subtotal() + WC()->cart->get_shipping_total() ); ?></td>
</tr>

I don't know how to make the TAX compute correctly, what code should I use for this, any help... thanks


Solution

  • You need to enable the tax for shipping:

    1) In your tax settings choosing the correct rate for it:

    enter image description here

    2) On the related shipping methods check that tax are enabled:

    enter image description here