Home›Support›English Support›[Resolved] Split: Currency switcher's location feature not always working as expected
[Resolved] Split: Currency switcher's location feature not always working as expected
This thread is resolved. Here is a description of the problem and solution.
Problem: The client was experiencing two issues: firstly, the currency format was not language-specific, causing the EUR to appear in the FR format on the EN site and vice versa. Secondly, the currency switcher was not working consistently across different settings and locations.
Solution: 1. We confirmed that the location-based currency feature was not functioning as expected and suggested that the issue might be related to the Maxmind Geolocation API. We recommended creating an API key for the feature to work properly and provided documentation links:
2. After further testing, we suspected a theme issue and advised the client to test with the Storefront theme while not logged in and to start a new browser session each time to confirm if the issue was theme-related.
3. We provided a hook that could help with currency formatting based on the user's store strategy:
We also reminded the client of the 'Currencies Per Location' feature and its benefits, linking to our documentation for more information: Currencies Per Location
If the solution provided is not relevant due to being outdated or not applicable to your case, we highly recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the issue persists, please open a new support ticket at WPML support forum.
This is the technical support forum for WPML - the multilingual WordPress plugin.
Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.
I removed the string translations and added the EUR format as described. When I opened this ticket, the formatting of the 2nd currency (EUR) was being applied to the main currency (GBP), and I confirm that's no longer the case.
There are still two problems:
1) The currency format is no longer language specific. So now on the EN site, the EUR is appearing in the FR format (1 234,00 €) and on the FR site, GBP appears in EN format. Currency format should be by language, not by currency. So this recent change in how currencies are formatted needs more work to allow for this. This is a major problem.
2) The currency switcher doesn't work consistently in all cases. I tried a number of configurations and tested using a VPN. Depending on settings and which country I'm in, the currency switcher is buggy. This includes not staying selected when navigating between pages (mainly on the FR site), or not changing when using the selector. I have tried changing the following settings, and I haven't found a single configuration where it works in all cases. Here are the setttings I've tried:
Main settings page (hidden link), 'Default customer location' = 'Geolocate (with caching support)' and 'No location by default'.
Multi-currency page (hidden link), 'Show currencies based on' = either value (language or location). On the same page, 'Currency displayed first' set to GBP for EN and EUR for FR and also, with 'Keep' for both languages.
I am in France, which may explain why the currency switcher keeps reverting to EUR on the FR site. I used a VPN and set my location to the UK and still have problems. For example, selecting a different currency doesn't always work while on the page, but then it does when going to a different page.
Note that the server has PHP page caching for users that aren't logged in. So please test in an anonymous browser window.
Languages: English (English )Spanish (Español )German (Deutsch )
Timezone: America/Lima (GMT-05:00)
After running further tests, this seems to be a theme issue.
Could you please run some tests with the currently activated Storefront theme and let me know if you can confirm that the issue is theme-related?
Take note, that you need to test this while not being logged in and you always need to start a completely new browser session.
If you can narrow down the source of the issue this way, then I can provide a WPML test site now which you can install the theme, so that we try if we can recreate the issue and take further steps.
I've done some testing and determined that the problem isn't the theme but server caching.
Basically, the first time the page loads, whatever currency is set at the time is cached. I tried using 'Geolocate with caching support' but this didn't help.
I found some related support tickets that discuss using cookies to keep track of the selected currency such as:
Currencies Per Location
This option can be used with or without WPML.
If you have customers in countries that speak the same language but use different currencies, you may want to configure your currencies based on your customers’ IP address or billing address.
This is useful if you would like to:
Enforce certain currencies for users based on their location or billing address.
Implement a pricing policy based on location.
Ok - thanks for the info. I'll change session to cookies and include the cookie value in my cache string.
If things still aren't working after that, I'll open a new ticket.
Thanks!
Manage Cookie Consent
We use cookies to optimize our website and services. Your consent allows us to process data such as browsing behavior. Not consenting may affect some features.
Functional
Always active
Required for our website to operate and communicate correctly.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
We use these to analyze the statistics of our site. Collected information is completely anonymous.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
These cookies track your browsing to provide ads relevant to you.