Geolocation with cache support

If you are not using a cache system, you can skip this section.

The geolocation and cache problem

Geolocation is powered by a WooCommerce PHP script which won’t run on cached pages. This can be confusing to customers. Here is an example of the problem:

  1. Hans from Germany visits the store and looks at a product.
  2. Hans sees the German price.
  3. The cache system saves the page in the cache.
  4. Charles from the UK visits the store and looks at the same product.
  5. As the page is cached, he sees German prices, rather than UK prices.

To solve this issue you have two options:

Load products price in background

If you enable this option, Price Based on Country fires an AJAX request on each page to refresh prices dynamically.

To enable it go to WooCommerce → Settings → Zone Pricing → General options and select Load products price in background.

Price Based on Country cache support

You must manually clear the cache of your cache plugin and your hosting provider after enabled Load products price in background.

Load products price in background supports default WooCommerce product types (Simple, Virtual, Downloadable, External, Grouped and Variable).

Pro version adds support to WooCommerce Subscriptions, WooCommerce Product Bundles, WooCommerce Product Add-ons and WooCommerce Bookings.

Currently, this option does not support WooCommerce Composite Products, if you are using this type of product you have to enable WooCommerce Geolocate with page caching support.

WooCommerce Geolocate with page caching support

Since version 2.4, WooCommerce adds an option to set the user’s location called “Geolocation with page caching support”. When you activate this option WooCommerce fires a javascript redirection with an extra parameter v=xxxxx. This parameter causes cache invalidation, the new page (with the parameter) will cache separately.

Default customer location

You must manually clear the cache of your cache plugin and your hosting provider after set Geolocate with page caching support.

See also