运费价格含税

In our store we have products which have various VAT. In shipping calculation it leads to incorrect shipping tax. I have investigated this problem deeper and decided to ask for a help. Things that I found out:

If you combine two products with various tax it often leads to incorrect tax calculation. Woocommerce takes the highest shipping price of products that are in cart (without tax) and adds the VAT of the most taxxed product.

For example we have two products:

  • Socks (10% VAT tax) shipped for 15,9€ total (without tax: 14,4545€, VAT: 1,4455€)
  • T-shirt (24% VAT tax) shipped for 16,9€ total (without tax: 13,6290€, VAT: 3,271€)

An outcome for this should be 16,9€ with 24% VAT (because it is greater than 15,9€ and the highest VAT Tax needs to be added for the shipping). Instead, it would be 17,92€. Why? Because the Woo took the 14,4545€ (because is the highest number) and added the highest tax -> 24%.

In Woocommerce you can only enter prices excluding tax. There is option in Tax tab to exclude VAT, but it would mean the tax in all shipping is 0%, which is incorrect.

The solution I had in mind was to add a filter in functions.php for tax calculation, which would take the provided shipping class costs as inclusive of tax.

The shipping calculation is located in class-wc-cart.php. I was not able to find the exact calculation code

I was also browsing stackoverflow, but the solutions provided are outdated and doesn't work.

Thanks to everybody, who might contribute to this problem.