Home Forums Plugins CURCY – WooCommerce Multi Currency Cached pages sometimes wrongly shows default currency (W3 Total Cache

Cached pages sometimes wrongly shows default currency (W3 Total Cache

  • Author
    Posts
  • #214527

    Bram de Leeuw
    Participant

    Hello,

    I have a problem where sometimes, cached pages display prices in the default currency, not in the designated currency for that specific page.

    This webshop is multilingual with Polylang Pro Polylang WC.
    Language detection is based on the domain the user visits:
    – norhage.no (default domain, Lang: Norwegian, currency: NOK)
    – norhage.de (lang: German, currency: EUR)
    – norhage.se (lang: Swedish, currency: SEK)

    Curcy is set up with Fixed price,
    caching options not set (json, ajax),
    auto-detect: Polylang,
    use session: off,
    switch currency by js: off,
    Add Query params: on (last change made today, hopefully this will help).

    Cache: W3 Total Cache
    advanced page_cache.

    I even added this snippet to my theme to “force” the correct currency:

    [code]
    /**
    * Force the currency to the one belonging to the domain
    * */
    function norhagewebshop_force_currency_per_domain(){
    if(!function_exists(‘pll_get_post_language’)){
    return false;
    }
    $settings = WOOMULTI_CURRENCY_Data::get_ins();
    switch(pll_current_language()){
    case ‘sv’:
    $currency_code = ‘SEK’;
    break;
    case ‘fi’:
    case ‘de’:
    case ‘en’:
    $currency_code = ‘EUR’;
    break;
    case ‘da’:
    $currency_code = ‘DKK’;
    break;
    case ‘nb’:
    default:
    $currency_code = ‘NOK’;
    }
    $settings->set_current_currency( $currency_code );
    }
    add_action( ‘init’, ‘norhagewebshop_force_currency_per_domain’ );
    [/code]

You must be logged in to see replies to this topic. Click here to login or register