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 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...
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 :
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.
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?
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.
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.
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.
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.
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.
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.