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.

Sun Mon Tue Wed Thu Fri Sat
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -
- 19:00 – 22:00 19:00 – 22:00 19:00 – 22:00 19:00 – 22:00 19:00 – 22:00 -

Supporter timezone: Asia/Kathmandu (GMT+05:45)

This topic contains 25 replies, has 2 voices.

Last updated by Subash Chandra Poudel 1 year, 8 months ago.

Assisted by: Subash Chandra Poudel.

Author Posts
February 22, 2023 at 12:10 pm #13088471

Jerzy Afanasjew

I am trying to: enable my customers to use USD/EUR/PLN based on their browser language and location

Link to a page where the issue can be seen: protestkit.eu

I expected to see: correct currency, USD for US users, EUR for europeans

Instead, I got: random currency which only updates to correct one when in cart

I am aware this is a common caching issue and can be resolved with cookies and function, but I have not found a solution on wpml forums specific to w3tc and I am a bit confused what is the most up to date workaorund. Looking forward to your response. Thank you.

I do not want to disable caching currency cookies as this would affect basically all my pages, its a shop. I believe this is the solution: https://wpml.org/forums/topic/wpml-chat-support-ticket-by-katerinak-1641242888/#post-10295347

But I need guidance how to implement it in w3tc.

February 22, 2023 at 6:37 pm #13091965

Jerzy Afanasjew

I found how to cache specific cookies in w3tc, but my now problem is that I dont see any cookie used for multicurrency feature. Do you no longer use "wcml_currency" coookie? Its a serious issue and not caching any of my product pages is not accaptable...

February 22, 2023 at 10:32 pm #13093457

Jerzy Afanasjew

I also tried the following solutions:

https://wpml.org/forums/topic/kinsta-cache-causing-issues-with-wcml-multi-currency/ (cookie instead of wcsession, unfortunately the snippet breaks site)

https://wpml.org/errata/caching-plugins-may-cause-issues-with-wcml-multi-currency-settings/ (kinsta snippet to serve custom cookie, also doesnt work)

https://wpml.org/forums/topic/wpml-chat-support-ticket-by-katerinak-1641242888/#post-10295347 (various snippets, tried to adapt them but failed or dont work)

February 24, 2023 at 8:11 am #13105609

Jerzy Afanasjew

Is anyone there? Hello?

February 24, 2023 at 8:20 am #13105631

Subash Chandra Poudel

Hi there,

Currently WCML currency related data are stored in WCSession to store them in cookies instead please use the following code in your child theme's functions.php file :

add_filter ('wcml_user_store_strategy', function ($strategy, $key) {
     return 'cookie';
}, 10, 2);

Once the code is added in your child theme functions.php file you can then see that the cookie wcml_client_currency holds your current currency. You can then exclude this cookie from cache to make sure the pages using currency features are not cached by your plugin and work properly.

Please let me know how it goes or if you need further help with the issue.

Regards,
Subash

February 24, 2023 at 10:30 am #13107107

Jerzy Afanasjew

thank you for the response, this snippet works but i am still having issues. i am debugging, i will update in 48 hours at most.

February 24, 2023 at 11:13 am #13107541

Subash Chandra Poudel

Hi there,

Sure please let me know the results of your further tests or if you need further help with this issue.

Regards,
Subash

February 26, 2023 at 6:41 pm #13117785

Jerzy Afanasjew

Thank you for the instructions. I think similar code here: https://wpml.org/wcml-hook/wcml_user_store_strategy/ has extra breaks which mess up the function, it crashed my website when I tried it earlier.

I was able to exclude cookie “wcml_client_currency” from caching, and it works for the most part. It does not however work in widgets, both default wordpress widget in my page menu (top rated products) and my theme products widgets on my main page. How do you recommend I proceed, considering that not caching main page is not desired?

Thank you for your stellar support.

February 27, 2023 at 10:20 am #13122073

Subash Chandra Poudel

Hi there,

Thank you for the updates.

I asked our team to fix the broken code at https://wpml.org/forums/topic/kinsta-cache-causing-issues-with-wcml-multi-currency/#post-11564155

Regarding the issue with Widget, I would need to take a closer look at your site. So I would need to request temporary access (WP-Admin and FTP), preferably to a test site where the problem has been replicated.

Your next answer will be private, which means only you and I have access to it.

IMPORTANT: Please take a complete backup of the site to avoid data loss.

Also Please let me know the exact steps I should follow on the site to see the issue.

Regards,
Subash

March 1, 2023 at 11:01 am #13143685

Subash Chandra Poudel

Hi there,

Thank you for the updates.

However I did test a few scenarios including the exact steps you sent me and the currency seems to show fine based on the location of the user every time I test. For example a recording of such test is in the link next:

hidden link

Can you please test again at your end and see how it goes? Also please test with a different browser and all browser history and caches cleared of All time and see how it goes.

Regards,
Subash

March 1, 2023 at 2:48 pm #13145869

Jerzy Afanasjew

the issue definietly persists on my end despite repeatedly clearing google chrome browser cache and using only incognito windows. I think you were not able to reproduce it because you opened 2 tabs at the same time. The issue dissapears upon page refresh, but the initial page load keeps showing me the currency that was used last, despite the VPN geolocation. please try again but do not open more than 1 tab at the same time and open only the main page, debug.protestkit.eu, not straight to product page. thank you for your time and support.

CapturFiles_2332.png
March 2, 2023 at 10:51 am #13153733

Subash Chandra Poudel

Hi there,

Thank you for the updates.

After further troubleshooting I think I can replicate the issue with the Homepage products widget currency.

I see sometimes the currency in homepage widget still shows the last currency used even though browser history/cache is cleared and location is changed.

To troubleshoot the issue further, can you please test by:

- Deactivating any other caching setup on the site or server like Theme cache or Server caching like Nginx caching.

- Deactivate all plugins except WPML, WooCommerce, W3total cache and any other critical plugins, also activate a default theme like twenty twenty one and see if it works.

- If it works, activate plugins and original theme one at a time to see which one starts the issue again.

The test is important because it looks like the issue here with homepage product widgets currency is not exactly with w3total cache and WPML but is an interference between other plugins/code/theme.

If possible please also setup a new test/staging site with minimal plugins and see if the issue persist there or not.

Regards,
Subash

March 2, 2023 at 7:46 pm #13158457

Jerzy Afanasjew

As recommended I set up new staging site at hidden link, issue persists with only default theme, w3tc, wpml and woocommerce active. Please advise how to proceed.

Please also check this thread for reference: https://wordpress.org/support/topic/add-cookie-for-wpml-multicurrency-feature/

I was unable to implement Page Fragment Cache and I am also unable to use the plugin "No Cache AJAX Widgets" for menu bar and especially front page.

March 3, 2023 at 12:11 pm #13163245

Subash Chandra Poudel

Hi there,

Thank you for setting up the staging site.

I am still working on it. I will send you an update here after I have a result from the tests.

Regards,
Subash

March 7, 2023 at 9:03 am #13186631

Jerzy Afanasjew

I set the new staging site, the issue still persist exactly as on the staging site that I preprared. Please see attached screenshots. Both are via VPN set to Paris. Both screenshots taken at homepage after visiting it directly with clear cache.

1) Cart displays EUR
2) Homepage product widget shows PLN

CapturFiles_2340.png
CapturFiles_2339.png

The topic ‘[Closed] Multicurrency feature conflict with w3tc caching plugin’ is closed to new replies.