PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Problem with cache plugin

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hello,

I need to get the selected currency with javascript in order to use it in some forms. I created the following function which retrieves it and then I pass it to my javascript file using wp_localize_script.

function get_current_currency(){
global $WPCS;
$currencies = $WPCS->get_currencies();
$current_currency_code = $WPCS->current_currency ?? 'USD';
return $currencies[$current_currency_code]??null;
}
I also found that there is already a javascript variable that contains it"wpcs_current_currency".

However, none of this works when I enable the cache (I use the plugin WP-Rocket). The current currency is correctly selected and the prices are correct but I can't retrieve the selected currency in javascript.

Any suggestions to solve this would be appreciated.

Thank you.

Hello

Yes wp-Rocket caches JS variables.

In this case, make an ajax request to get the current currency

Hello,

Ok. Noted.
Thanks.

Welcome;)