• Resolved protestkit

    (@protestkit)


    Hello, I am having issues with caching my ecommerce site utilizing WPML multicurrency issue. Sometimes I see EUR prices, sometimes I see USD prices, despite where I am located. It is obviously a caching issue because after clearing cache sometimes I see only USD sometimes only EUR prices + the issue has been widely reported on WPML support forum. Some plugin authors or hosting providers have provided solution. I found a solution posted by a user of WP Super Cache. It requires defining a cookie which will cause my pages to be cached separately, like this:

    do_action( 'wpsc_add_cookie', 'wcml_currency');

    Please advise how to proceed with this solution in w3tc. Thank you.

    More details: https://wpml.org/forums/topic/wpml-chat-support-ticket-by-katerinak-1641242888/#post-10295347

    Looking forward to hearing from you

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @protestkit

    Thank you for reaching out and I am happy to assist you with this.

    In Performance>Cooke Groups, you can create group of Cookies by specifying names in the Cookies field. Assign a set of Cookies to ensure that a unique cache is created for each Cookie group.

    Have you tried settings this up and if not please give it a shot and let me know if this helps!

    Thanks!

    Hello guys, was this solution working? Im encountering similar problem with WCML currency switcher on https://www.seasonsnow.eu.
    Caching plugin also cache the currency so on some pages it shows one and on other another currency.
    What should cookie group look like in case of WCML? Im not sure how to set it correctly.

    Thanks for help.

    Silvester

    Thread Starter protestkit

    (@protestkit)

    @silvo37

    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 (check “enabled”, do not check “cache” in the relevant Manage Cookie Groups w3tc Cache Groups settings, you need to create a cookie group there and simply add “wcml_client_currency” there) to make sure the pages using currency features are cached properly.

    @vmarko

    Thank you for the instructions. 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 widgets on my main page. How do you recommend I proceed, considering that not caching main page is not desired? Thank you for your support.

    • This reply was modified 1 year, 9 months ago by protestkit.
    • This reply was modified 1 year, 9 months ago by protestkit.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @protestkit

    This depends on how the widgets are embedded. The Page Fragment Cache may be the solution for this as it will exclude the specific part of the page (widgets in your case) or fire the widgets with ajax calls.
    In any case, I’ve brought this to the team and we are considering implementing a solution for this.

    Thanks!

    Thread Starter protestkit

    (@protestkit)

    Thank you for your response.

    Do you have any suggestion why when browsing as admin does the issue persist in one widget and not in another one (one currency in menu bar widget, different currency on home page product widget), considering I have caching disabled for my admin account? Issue dissapears when I disable w3tc.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @protestkit

    Thank you for your feedback.

    It would help if you could share a screenshot. To confirm, the problem persists, when you are logged in and the caching is disabled for logged in users?
    Thanks!

    Thread Starter protestkit

    (@protestkit)

    That is correct, however as logged in user only 1 currency displays anyway, probably its saved per user, perhaps that is not the best troubleshooting way.

    See these 2 screenshots when browsing in an incognito tab with VPN set to Paris:

    1. Main page widgets show random currency – https://i.postimg.cc/cLR7BPxy/Captur-Files-2336.png
    2. Navigating to any product page updates currency to the correct one (EUR) – https://i.postimg.cc/GpbF7ztB/Captur-Files-2337.png

    I confirmed the issue to be present only when w3tc caching (I think page caching if I recall correctly) is enabled, definietly does not persist after disabling w3tc. The issue persists with only default theme, w3tc, wpml and woocommerce enabled. Going to product page updates currency correctly, but starting at home page displays random currency. WPML suggests there is some homepage caching going on that applies even to users browsing with cleared cache… Does that ring any bell?

    • This reply was modified 1 year, 8 months ago by protestkit.
    • This reply was modified 1 year, 8 months ago by protestkit.
    Thread Starter protestkit

    (@protestkit)

    If I not only disable the cookie “wcml_client_currency” in Cache Groups, but also in Page Caching setting “Rejected cookies:” the issue is fixed. However as far as I understand the disclaimer “Never cache pages that use the specified cookies.” this would disable page caching for all my pages that feature some sort of a currency widget. Please confirm. If so, this can’t be the solution.

    PS. I have server side caching disabled.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hey @protestkit

    Sorry for the late reply. I’ve brought this to the team and we are working on a couple of solutions for this.
    I’ll get back to you once I have more information.

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Add cookie for WPML multicurrency feature’ is closed to new replies.