Skip Navigation

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 2 replies, has 1 voice.

Last updated by Andreas W. 4 days, 21 hours ago.

Assisted by: Andreas W..

Author Posts
February 26, 2025 at 3:51 pm #16752012

khalidA-55

Background of the issue:
I am trying to create a dedicated French (Morocco) version of my WooCommerce site using WPML, with unique pricing in MAD for Moroccan visitors. I have duplicated the French content to a new French (Morocco) version (fr-ma) and configured WooCommerce Multilingual to assign MAD as the currency for that variant. I explored using a custom code snippet with the WPML Hook (wcml_client_currency) to override the currency based on geolocation, but it requires an external solution like GeoIP Detection. I also considered geolocation-based redirection using plugins like IP2Location Redirection and GeoTargeting WP, but I am concerned about compatibility with caching plugins like WP Rocket.

Symptoms:
I need Moroccan visitors to be automatically redirected to the French (Morocco) version to see the correct pricing in MAD. I am facing challenges with geolocation and caching, as some plugins warn that caching will break redirection.

Questions:
Given the need for a dedicated French (Morocco) version with unique pricing and the challenges with geolocation and caching, which approach do you recommend?
Has anyone successfully implemented geolocation-based redirection or dynamic currency switching in a WPML setup while using WP Rocket or similar caching plugins?
What configuration or best practices helped to ensure dynamic content isn’t served from cache?
If you have other ideas or plugins that have worked well in a similar scenario, I’d appreciate your input and recommendations.

February 28, 2025 at 12:15 pm #16760644

khalidA-55

could you please respond! it's over 2 days now?! thanks

March 1, 2025 at 5:03 pm #16764234

Andreas W.
Supporter

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

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

Hello,

Our apologies for the delay in answering as we are handling a high amount of ticket requests.

The "Currency by Location" feature of "WooCommerce Multilingual & Multi-Currency" is designed to work with the Geolocation Feature of WooCommerce and requires a MaxMind API key:
https://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/#more-multicurrency-features

This feature will only work for logged-in users.

If needed, you can use the wcml_geolocation_get_user_country filter hook to override the default geolocated country and use the billing or shipping address instead.

Source:
https://wpml.org/documentation/related-projects/woocommerce-multilingual/multi-currency-support-woocommerce/#more-multicurrency-features

How to set up Geolocation in WooCommerce:
https://woocommerce.com/document/maxmind-geolocation-integration/

Best regards
Andreas