Although this article refers to the Currency Switcher for WooCommerce, the possible causes of issues apply to all the Aelia plugins that include a geolocation feature.
The geolocation logic has been thoroughly tested. When it looks like it's not working properly, the issue is almost always due to a misconfiguration or to external causes. Most of the possible causes can be found below.
- Please make sure that you check each possibility carefully. It's easy to overlook some settings, such as caching, or a non-standard reverse proxy, and assume that the geolocation feature itself is not working properly. Based on our experience, that is rarely the case. The root cause of geolocation issue is almost invariably external to our plugins.
- Before you perform the troubleshooting steps, we recommend that you enable the debug log in the Currency Switcher settings. The log will contain entries showing what IP address was received by the Currency Switcher, and to which country and currency such address was resolved. You can find a step by step guide, showing how to enable and review the log, here: How to view the geolocation resolution log from the Currency Switcher.
1. The visitor has already a country/currency assigned to him/her
Geolocation is triggered once per visitor. The detected information (country, currency, etc) is then stored against visitor's session and, if he/she is logged in, against the profile, in the database. The stored information is then used from that moment on, and no further geolocation is performed.
During testing, it's crucial to use private/incognito browser sessions, and close them after each visit. This ensures that the cookies set by the plugins to track the detected country and currency are deleted, and that the geolocation is performed again at the next visit.
2. The geolocation feature is disabled
The geolocation feature is disabled by default. To enable it, go to Currency Switcher Options > Geolocation, tick the Geolocation option and save the plugin settings.
3. The exchange rate for one or more currencies is missing or not valid
As indicated in Currency Switcher Options page, the exchange rate for each currency is compulsory, as it's used for reporting. If this information is missing, the affected currency is ignored by the plugin. When a currency is ignored by the Currency Switcher, it cannot be assigned to a visitor after detecting his geolocation, therefore the Currency Switcher will use the default currency instead.
It's also important to note that exchange rates must use the point as a decimal separator, and they must not contain any thousand separator. For example, 123.456 (note the point) is a valid exchange rate, while 123,456 (using the comma) is not. An exchange rate using the incorrect separator would be considered invalid, and that would also cause the currency to be ignored.
4. A caching system, or plugin, is serving stale content
If you use plugins like W3 Total Cache or Super Cache, or a caching service (Squid, Varnish, etc), your server may be serving your visitors stale pages. In such case, the geolocation logic is not even invoked, thus making it look like it's not working. This is described in more details in the following article: The currency conversion/detection doesn't seem to work with caching enabled.
To fix this issue, there are two possible solutions:
- If your caching system/plugin supports dynamic caching, you will simply have to configure it correctly. You can find the instructions to configure dynamic caching for some common caching systems in our knowledge base: How to add dynamic caching to your site.
- If your caching system/plugin does not support dynamic caching, you will have to disable caching on catalogue pages and product pages, or use a workaround solution such as our WooCommerce Cache Handler plugin. The article about dynamic caching, linked above, also covers this case and provides further details.
5. The user accessed the site when the Currency Switcher was active, but before geolocation was enabled
Geolocation detection is executed only the first time a visitor comes to your site. If a visitor comes to your site when geolocation detection is disabled, he is assigned the default currency, which then persists for subsequent visits (see How does Currency Switcher geolocation detection mechanism work? for more information).
6. Your site is behind CloudFlare
For more information, please refer to the related knowledge base article: How to add dynamic caching to your site.
Also, please be aware that CloudFlare replaces the visitor's IP with their own. If the geolocation still doesn't work after installing the Cache Handler plugin, you will need to install the WordPress CloudFlare plugin as well. That will ensure that the correct IP is passed to the Currency Switcher.
7. Your site is behind Sucuri CloudProxy
Sucuri replaces the visitor's IP with their own, making all users appear with the same IP address. This prevents the Currency Switcher from detecting visitor's location. This is documented in the Sucuri knowledge base: Sucuri - Same IP for All Users.
Sucuri CloudProxy also doesn't support dynamic caching, and might serve the wrong content to your visitors. Due to that, you will have to disable Sucuri's caching, or use a workaround such as our WooCommerce Cache Handler plugin. For more information, please refer to the related knowledge base article: How to add dynamic caching to your site.
8. Your site is behind a reverse proxy that uses non-standard headers
The Currency Switcher can deal with standard reverse proxies, but some of them use non-standard headers. In such case, some custom code might be needed to properly determine the visitor's IP address. Your code should add a wc_aelia_currencyswitcher_visitor_ip filter and return the correct IP address, based on your server's configuration.
For reference, the geolocation feature looks for visitor's IP address in the following headers (order by priority, highest to lowest):
We also recommend to read the following article, which will help checking what IP address is passed by the server to the geolocation logic: How to view the geolocation resolution log from the Currency Switcher.
9. Your visitors are using a proxy
If visitors are coming to your site via a proxy server, then they IP address has been replaced by the one used by the proxy server. In such case, there is no way to detect the original IP address, as the site is actually not communicating with the visitor's computer, but with the proxy itself.
10. You updated WooCommerce, but you are using an old version of the Aelia plugins
Before you update WooCommerce, you must always make sure that you update the Aelia plugins to the latest versions. You can download them from the email you received when you completed your orders, or from the My Account section on our site.
There may be other factors that can impact on the geolocation mechanism, which vary depending on the specific condition and environment. Should you encounter any issues with the geolocation feature and none of the above solution seems to apply, please feel free to open a support ticket and we will be happy to assist you.
11. Another plugin might be interfering with the geolocation and currency selection features
Other plugins may be preventing the geolocation and automatic currency selection features from working correctly. If you use plugins that introduce features related to currency management, you will have to disable them to prevent conflicts.
To determine if one or more of the installed plugins are interfering with the geolocation feature, you can simply go by exclusion:
- Disable one of the 3rd party plugins (except WooCommerce and plugins developed by Aelia).
- Reload the site, ensuring that you follow the instructions to test the geolocation.
- If the issue persists, repeat from #1 with the next plugin. If not, then you will have an indication that the last plugin you disabled might be contributing to the issue. In such case, you can inform both us and its author, so that we can find a solution.
There might be some custom code forcing the currency
The Currency Switcher allows to set the currency via code, by writing a simple filter. If you, or one of your developers, wrote such customisation in the past, the code may still be in your theme's functions.php, overriding the currency detection.
- How does Currency Switcher geolocation detection mechanism work?