Skip to content Skip to sidebar

This thread is resolved. Here is a description of the problem and solution.

Problem:
You are trying to use Cloudflare caching to improve your site's TTFB metrics but encounter issues with the currency switcher in WooCommerce. The currency switcher becomes buggy, not changing currencies correctly on the same page, though it updates when navigating to another page.
Solution:
We suggest changing the storage strategy of the currency from the WooCommerce session to a cookie. This can help maintain currency consistency across pages when using caching solutions like Cloudflare. You can implement this change using the

wcml_user_store_strategy

hook. For more details on how to apply this hook, please visit https://wpml.org/wcml-hook/wcml_user_store_strategy/.

If this solution does not resolve your issue or seems outdated, we recommend opening a new support ticket. We also advise 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. For further assistance, please contact us through the 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.

Tagged: 

This topic contains 9 replies, has 0 voices.

Last updated by Laura 1 week ago.

Assisted by: Laura.

Author Posts
July 19, 2025 at 2:42 am #17252106

kasperv-6

Background of the issue:
I am trying to use the cache from Cloudflare to improve my site's TTFB metrics. The only thing I can't do is turn on the cache in Cloudflare. I have tried geolocation with page caching support in the WooCommerce settings, but that didn't help. I really would like to have the caching from Cloudflare activated on the website.

Symptoms:
Currency switcher gets very buggy, can't change currency anymore, but when navigating to the next page the currency did change. Navigating back the currency is again the previous one, although adding to cart on that page uses the right currency.

Questions:
Is there any way how I can activate Cloudflare caching without breaking the functionality of the currency switcher?

July 22, 2025 at 2:37 pm #17259881

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Hi,

Thanks for contacting us.

I asked for a second opinion about how to handle this.

July 23, 2025 at 4:28 am #17261583

kasperv-6

Thank you. I'll be waiting

July 23, 2025 at 8:59 am #17262768

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

There is a staging site with Cloudflare installed where we can run some tests?

July 23, 2025 at 9:28 am #17262943

kasperv-6

No, I cannot create a staging right now and activate cloudflare caching without affecting the other site as well unfortunately.
Are you guys to recreate the issue on a testing environment on your side maybe?
Dont you have some general guidelines on how to handle cloudflare caching in combination with the multicurrency plugin?? It could be as simple as excluding a cookie that holds the currency the customer has chosen. I just couldnt find a cookie in the network tab, so I dont know how currency is stored for a visitor

July 23, 2025 at 2:02 pm #17264347

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

We can't recreate the issue because we'd need the exact same settings you're using, and it might be not possible. I'm quite sure if we set up one of our test servers, we wouldn't be able to recreate the issue. Cloudflare is widely used so if there was a bug like the one described, we'd likely get more reports, and that's not the case.

The currency is stored in the WC session, but you can use wcml_user_store_strategy to change it to cookie, some plugins (like WP Rocket) do this by default.

July 24, 2025 at 7:35 am #17266242
kasperv-6

Ok, that sounds like a better idea to try, I will experiment with that.
Another issue Im running into is that the default currency for someone who visits my site for the first time is always USD. It doesnt matter if I use an incognito browser or a normal browser.
How can I force the use of my base currency IDR for first visitors at all times. Then if they want to change the currency to smt else thats fine.
Can you explain why it always uses USD.
I have my woocommerce setting now changed instead of geolocation to shop region/country, but that didnt change it. Also I dont see an option in the WCML settings to force IDR to be the default currency.
I have also tried adding some php code that forces the wcml_client_currency cookie to be set to IDR, but that doesnt work on first pageload, only when navigating to the next page the currency changes into IDR instead of USD.
Weird behaviour, how would I be able to fix this?

New threads created by Laura and linked to this one are listed below:

https://wpml.org/forums/topic/default-currency-is-always-usd/

July 24, 2025 at 9:52 am #17266784

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

I split the ticket since the initial issue is different. Can we close here or do you want to test it before? I'm not sure how much support we can still provide.

July 24, 2025 at 10:15 am #17266863

kasperv-6

I will get back to you guys if I cant figure it out. You can close it. Thank you!

July 24, 2025 at 10:33 am #17266933

Laura
WPML Supporter since 05/2018

Languages: English (English ) Italian (Italiano )

Timezone: Europe/Rome (GMT+02:00)

Thanks!