Geolocation with cache support
The geolocation and cache problem
Geolocation is powered by a WooCommerce PHP script which won’t run on cached pages. Here is an example of the problem:
- Hans from Germany visits the store and looks at a product.
- Hans sees the German price.
- The cache system saves the page in the cache.
- Charles from the UK visits the store and looks at the same product.
- As the page is cached, he sees German prices rather than UK prices.
This problem confuses customers.
Load products price in the background
- The plugin adds an HTML wrapper to each product’s price on the page. This wrapper matches each piece of HTML with the product.
- When a customer visits a page on the site, an AJAX call is fired in the background, which returns the price of each product.
To enable/disable the “Load products price in the background” option, go to WooCommerce > Settings > Pricing zones > Options:
The WooCommerce option “Geolocate with page caching support.”
As an alternative to the “Load products price in the background” option, WooCommerce includes another feature that also solves the geolocation and cache problem.
To enable it, set the “Default customer location” option to “Geolocate (with page caching support).”