Skip to content
Advertisement

woocommerce_tax_rates table missing from database, even though taxes are configured?

I have configured taxes in Woocommerce (with the plugin EU/UK VAT Compliance for WooCommerce). This plugin configures them inside Woocommerce, see screenshot (yes, the menu’s are in Swedish, but you get the point).

So where are the taxes stored? The sql table woocommerce_tax_rates isn’t there, see screenshot. But the tax rates are clearly stored somewhere since they are visible in the backend. I’m not looking at the wrong database, since things like update_post_meta() do what they should. Did Woocommerce change the location of taxes and I just can’t find the new specifications through Google, or did I completely miss something obvious?

And no, it’s usually not necessary to query the wpdb directly. But I tried to get the tax rates through

$location = array('country' => 'SE', 'state' => '', 'postcode' => '', 'city' => '')
WC_tax::get_rates_from_location('', $location);

which returns an empty string. Maybe I’ve written something in the wrong format, but I cannot check how the database is written, since I can’t find it? And I want to understand this weirdness anyway.

Also, the store itself seems to work as it should. The products have tax, and it looks correct at the checkout.

Advertisement

Answer

After an unreasonable amount of googling and trying and digging in woocommerce source code, I realized I had been searching in completely wrong places. The decisive clue came when I realized I could query SELECT * FROM 'wp_woocommerce_tax_rates' directly in phpMyAdmin.

And that’s where the problem was, phpMyAdmin not showing all the tables in the left column. phpMyAdmin settings->navigation tree->maximum amount of objects in a branch was too low (come on phpMyAdmin, you could put up a little warning sign?).

Also, I had been doing mistakes when querying WC_tax. A query in the wrong format doesn’t necessarily result in an error, it just returns an empty array.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement