Incorrect WooCommerce tax calculation: here is the fix

One of the problems that I came across while working with the WooCommerce plugin for Prêt à Porter Femme, webfront for a chain of Parisian boutiques that sell trendy women’s clothing was that the tax was getting collected wrongly.

For example, if you are selling a product for 100 euros, and want to declare that as tax inclusive, set a tax of 20%, and hope that the cart will be set as 80 euros (product price) + 20 euros (tax), you will be disappointed to find that WooCommerce doesn’t calculate that way. So instead of seeing a VAT of 20 euros (20% of 100 euros), you will see a VAT of 16,67 euros.

Worked out the fix, this will work if want to declare prices that are inclusive of taxes. Sharing the code for 20 euros. Send me a mail at sourav[@]choudhury[.]fr once you have sent the payment.