• Adiie9

    (@ad33lx)


    Hi,

    I have custom made theme and functions and have custom currency changer. I want to save cache files based on currency selected and it should load the same cache file of selected currency.

    
    //--------array of currencies------
        $currencies_list=array();
        $currencies_list['AED']=1;
        $currencies_list['USD']=2;
        $currencies_list['GBP']=3;
    //----------detect currency from cookie-------
            $currency_get='AED';
            if(isset($_COOKIE['currency']))
            {
              if(trim($_COOKIE['currency'])!='')
              {
                $currency_get=$_COOKIE['currency'];
              }
            }
    //---------update list of filenames for WP cache-------
    add_filter('all_supercache_filenames', function($filenames) {
        global $currencies_list;
        foreach($currencies_list as $c=>$v)
        {
          $filenames[]='index-'.$c.'.html';
          $filenames[]='index-https-'.$c.'.html';
          $filenames[]='index-'.$c.'.html.php';
        }
        
        return $filenames;
    });
    //------------detect currency and set WP cache file name--------
        add_filter('supercache_filename_str', function($str)
        {   
            $currency_get='AED';
            if(isset($_COOKIE['currency']))
            {
              if(trim($_COOKIE['currency'])!='')
              {
                $currency_get=$_COOKIE['currency'];
              }
            }
    
          if($currency_get!='AED' && $currency_get!='')
          {
            $str.='-'.$currency_get;
          }
            return $str;
        });
    
    

    This is not working at all, it is always creating one index-https.html file and if I clear cache and re-load page with currency other than AED, it creates that file suppose index-https-GBP.html but if I switch back to AED, it generates index-https.html and it always load index-https.html even if I change the currency again to GBP or any other.

    • This topic was modified 6 years ago by Adiie9.
    • This topic was modified 6 years ago by Adiie9.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Custom currency converter issue with wp super cache’ is closed to new replies.