• Hi there,

    SuperCache seems to also cache from the Currency Converter. Can we somehow exclude this from being cached?

    Best,
    El

Viewing 4 replies - 1 through 4 (of 4 total)
  • Saša

    (@stodorovic)

    If it’s WooCommerce Currency Converter Widget then I’ve found that it stores currency into cookie woocommerce_current_currency. It’s possible to exclude this cookie from caching. Could you check exact names of cookies?

    Thread Starter EasyEl

    (@easyel)

    Hi Sasa,

    it is literally “woocommerce_current_currency” that stores the value. I would also like to exclude

    aelia_cs_selected_currency
    aelia_customer_country
    aelia_customer_state
    aelia_billing_country
    aelia_tax_exempt

    Cookies from being cached.

    Best,
    Elmar

    Saša

    (@stodorovic)

    I’ve created an example for WPSC plugin:

    <?php
    
    class WPSC_Plugin_Currency_Converter {
    
            public function __construct() {
                    add_cacheaction( 'wp_cache_get_cookies_values', array( $this, 'get_cookies_values' ) );
            }
    
            private function currency_cookies() {
                    return array(
                            'woocommerce_current_currency',
                            'aelia_cs_selected_currency',
                    );
            }
    
            public function get_cookies_values( $string ) {
                    foreach ( $this->currency_cookies() as $cookie_name ) {
                            if ( isset( $_COOKIE[ $cookie_name ] ) && is_string( $_COOKIE[ $cookie_name ] ) ) {
                                    $string             .= $cookie_name . '=' . $_COOKIE[ $cookie_name ] . ',';
                                    $super_cache_enabled = false; // Create only wp-cache file.
                                    wp_cache_debug( 'currency_converter: detected cookie ' . $cookie_name );
                            }
                    }
    
                    return $string;
            }
    }
    
    new WPSC_Plugin_Currency_Converter();
    

    You need to set “Simple” cache delivery method instead of “Expert”. Also, I recommend to you enable logging (Debug tab) – you will see if cookies are detected.
    In next releases of WPSC (PR 657), I think that we could improve this plugin. You will select that “selected cookies” will be cached or no.

    Thread Starter EasyEl

    (@easyel)

    Hi Sasa,

    I got it to work – appreciate the feedback! Actually most of the issues I had where caused by GDPR consent plugins even when cookies were set to essential. Not sure what causes this but there is definitely a challenge to implement sich together with cookies/caching.

    Best,
    El

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘WooCommerce Currency Converter cached’ is closed to new replies.