Woocommerce Tax Not Calculating

The Woocommerce tax not calculating problem is the result of a poorly designed query.

I have been setting up a new Woocommerce store for a the candle company I work for part time.  During the testing process I discovered that the tax calculation had stopped functioning.  I was convinced that this had worked at one time but suddenly had ceased.  Worse, this seemed to occur after importing all the Zip codes and tax rates.

After much trial and error I discovered that the problem is the algorithm used to determine the tax.

The data is stored in two tables:

wp_woocommerce_tax_rate_locations
wp_woocommerce_tax_rates

The first table is the key.  If you create a Zip code based entry, for arguments sake lets use a California code of 91387 which happens to be include Canyon Country areas, then your entry is going to look like this:

wc-tax-1

 

Here is where the problem starts.  On the Cart page the store doesn’t know which ‘city’ the buyer is from and the query appears to ‘AND’ the two entries so it doesn’t find the tax information provided in the cart by the customer as being in the 91387 Zip code AND Canyon Country.  In the checkout itself, once the customer enters the City and the Zip code the tax should be calculated correctly.

The easiest solution to this problem is to simply leave the ‘City’ blank when adding Zip codes and tax rates.

Leave a Reply

Your email address will not be published. Required fields are marked *