Can customers be shown the correct VAT rate as soon as a visitor comes to the site / some prices seem to be wrong?

What is meant here is, is it possible to detect which country a visitor is coming from (using their IP address), and then base the prices that they see upon this, by assuming initially that their IP address country is the same as their taxation country?

The answer to this question is yes: this is now a feature of WooCommerce core which you simply need to turn on – the setting for the default customer address in Settings > General – set it to “Geolocate”. WooCommerce core will then use the visitor’s country for its tax calculations. The visitor can over-ride this in various ways, for example by explicitly choosing a country using a widget or drop-down menu, or choosing their country at the checkout.

Here is a screenshot of the WooCommerce setting in Settings -> General:

Geolocation setting in WooCommerce

Note that once a country has been selected in a widget or drop-down, this is then saved in the visitor’s session (or one may be set from the customer’s saved address if they log in to the site). If you, for example, decide to test your store by visiting it in the same browser using different VPNs to come from different countries, you may not see what you expected because of this. A genuine test needs to start with a new, completely empty browser session (e.g. by closing all windows of the browser, and opening a new ‘private’ or ‘incognito’ window when you re-open it).

This behaviour, of saving a visitor’s previous selection, includes saving that prices should be shown without VAT, if relevant (e.g. if that option was selected from a menu or widget).

If you wish to turn off this auto-detection behaviour, then add this in your wp-config.php file, after the opening <?php line:


Investigating problems

Note that the above feature is not compatible with naive page cacheing, i.e. having the same cached version of a page served to all visitors from all countries. Your page cache needs to be country-aware (e.g. WP Optimize Premium, with the appropriate setting turned on).

If you add these two lines (the second being for compatibility with expected future changes) in your wp-config.php file, after the opening <?php line …

define('WC_VAT_DEBUG', true);

… then you can visit a page, use your browser’s “View Source” function to see the HTML of the page, scroll down to near the bottom, and you should be able to see a debugging comment in the HTML to tell you which country was detected (using the standard ISO two-letter country code):

Debugging HTML comment

Posted in: WooCommerce EU/UK VAT Compliance