Skip Navigation

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:

https://wpml.org/wcml-hook/wcml_user_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.

This topic contains 5 replies, has 2 voices.

Last updated by Andreas W. 1 year, 1 month ago.

Assisted by: Andreas W..

Author Posts
March 15, 2024 at 2:55 pm #15415025

willR-4

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.

Thanks for your continued help.

March 15, 2024 at 5:07 pm #15415590

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

I can confirm that the location-based feature does not work as expected on your site.

The issue might be related to the Maxmind Geolocation API which is required, as you need to create an API key for the feature to work:

More details:
https://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/#currencies-per-location

hidden link

Did you already create a new API key for the site URL new.coolicebox.com?

March 18, 2024 at 8:33 am #15419533

willR-4

Yes, I created a new API key for the site when I enabled Geolocation.

Screenshot 2024-03-18 at 09.33.03.png
March 19, 2024 at 6:39 pm #15428424

Andreas W.
WPML Supporter since 12/2018

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.

March 20, 2024 at 12:06 pm #15431149

willR-4

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:

https://wpml.org/errata/caching-plugins-may-cause-issues-with-wcml-multi-currency-settings/
https://wpml.org/forums/topic/woocommerce-multilingual-with-multi-currency-and-wp-rocket-issue/

I checked my site and none of the cookies mentioned are set by default (I'm guessing the session is being used instead).

The first link above mentions how to do add a cookie via code. The second article mentions other cookies used by WP Rocket.

Do you know whether these cookies are set by WPML, or is this done in code by WP Rocket?

Is there some way to configure WPML to set the currency via cookie instead of session?

March 20, 2024 at 1:32 pm #15431735

Andreas W.
WPML Supporter since 12/2018

Languages: English (English ) Spanish (Español ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

This hook is what you are looking for:
https://wpml.org/wcml-hook/wcml_user_store_strategy/

----

From our documentation:

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.

Source:
https://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/#currencies-per-location

Best regards
Andreas

March 21, 2024 at 9:04 am #15435103

willR-4

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!