Skip Navigation

Open

Symptoms

If you use a caching plugin on a WooCommerce site that uses the WCML multi-currency feature, your customers may see incorrect prices or not be able to change currencies.

Workaround

We are working with popular caching plugins to improve compatibility. In the meantime, we recommend that you exclude pages from cache that use browser cookies and multi-currency.

4 Responses to “Caching plugins may cause issues with WCML multi-currency settings”

  1. Seems on product pages that multi-currency does not seem to work properly as prices in USD for USD customers are not the same as for EU / EUR customers. This is especially the case with shipping fees. We are using WP Rocket and we would prefer not to exclude the currency converted on WooCommerce category or product pages. But perhaps you could have a look see what can be done and whether this really is currency converter related.

  2. all kinsta user ( nginx cache) have the same problem but this case is old …. wpml look to solve it before 2050 ??

  3. SOLUTION FROM KINSTA ( For NGINX):

    1: Add the following php code via either a code editor plugin or via the functions.php file somewhere or in child theme’s functions.php file. This will create the “wcml_custom_currency_cookie” cookie:
    
    function wcml_set_custom_currency_cookie( $currency = false ) {
    if ( is_admin() && !( defined(‘DOING_AJAX’) && DOING_AJAX ) )
    return;
    if ( !empty( $currency ) ) {
    setcookie(‘wcml_custom_currency_cookie’, $currency, time() + 60*60*24*7, ‘/’);
    return;
    }
    if ( empty( $_COOKIE[‘wcml_custom_currency_cookie’] ) && function_exists( ‘get_woocommerce_currency’ ) ) {
    setcookie(‘wcml_custom_currency_cookie’, get_woocommerce_currency(), time() + 60*60*24*7, ‘/’);
    }
    }
    add_action(‘wcml_switch_currency’, ‘wcml_set_custom_currency_cookie’);
    add_action(‘init’, ‘wcml_set_custom_currency_cookie’);

    
    2: Exclude cache for the $wcml_custom_currency_cookie http_cookie via nginx (Us in Support can only modify/edit these since we’re a managed hosting platform.
    
    3: Strip all $http_cookies that are still cached on cache HITS, this will avoid the cookie from being set up on pages that hit the Kinsta cache to avoid bypassing Kinsta cache where we don’t need to bypass Kinsta cache. As you know, cache on WordPress is very important to keep site speed optimized!

    –> Also only something in Kinsta Support can do via Nginx.

Leave a Reply

Please leave here comments about this page only.
For technical support and feature suggestions, head to our forum. We are waiting there!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>