Currency change with custom code and GTRANSLATE 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 pleaseIf 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.
Quote from Daxiorek on April 3, 2024, 10:49Hello, I have added custom code from your website to change the language after detecting a currency, it works well, but the problem is with the currency cache, currencies are kept in the cache all the time. My website is Genoplast.comadd_action('init', function () { // Zmieniamy hook z 'wp_head' na 'init'
if (!defined('CURRENCY_ALREADY_SET')) {
// Sprawdzamy język użytkownika
$lang = isset($_SERVER['HTTP_X_GT_LANG']) ? $_SERVER['HTTP_X_GT_LANG'] : '';// Ustalamy globalną zmienną dla WooCommerce Currency Switcher
global $WOOCS;// Ustalamy walutę na podstawie języka
switch ($lang) {
case 'de':
case 'sk':
$currency_code = 'EUR';
break;
case 'en':
$currency_code = 'GBP';
break;
case 'uk':
$currency_code = 'UAH';
break;
case 'cs':
$currency_code = 'CZK';
break;
case 'pl':
default:
$currency_code = 'PLN';
break;
}// Ustawiamy wybraną walutę w WooCommerce Currency Switcher
if (isset($WOOCS)) {
$WOOCS->set_currency($currency_code);
}// Dodajemy nagłówki kontrolujące pamięć podręczną, aby uniknąć cachowania strony
header('Expires: Tue, 03 Jul 2001 06:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');// Ustawiamy stałą, aby zapobiec ponownemu ustawianiu waluty podczas jednego ładowania
define('CURRENCY_ALREADY_SET', true);
}
});
Hello, I have added custom code from your website to change the language after detecting a currency, it works well, but the problem is with the currency cache, currencies are kept in the cache all the time. My website is Genoplast.com
add_action('init', function () { // Zmieniamy hook z 'wp_head' na 'init'
if (!defined('CURRENCY_ALREADY_SET')) {
// Sprawdzamy język użytkownika
$lang = isset($_SERVER['HTTP_X_GT_LANG']) ? $_SERVER['HTTP_X_GT_LANG'] : '';
// Ustalamy globalną zmienną dla WooCommerce Currency Switcher
global $WOOCS;
// Ustalamy walutę na podstawie języka
switch ($lang) {
case 'de':
case 'sk':
$currency_code = 'EUR';
break;
case 'en':
$currency_code = 'GBP';
break;
case 'uk':
$currency_code = 'UAH';
break;
case 'cs':
$currency_code = 'CZK';
break;
case 'pl':
default:
$currency_code = 'PLN';
break;
}
// Ustawiamy wybraną walutę w WooCommerce Currency Switcher
if (isset($WOOCS)) {
$WOOCS->set_currency($currency_code);
}
// Dodajemy nagłówki kontrolujące pamięć podręczną, aby uniknąć cachowania strony
header('Expires: Tue, 03 Jul 2001 06:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
// Ustawiamy stałą, aby zapobiec ponownemu ustawianiu waluty podczas jednego ładowania
define('CURRENCY_ALREADY_SET', true);
}
});
Quote from Pablo Borysenco on April 3, 2024, 11:50Hello
Please paste your license key here - https://share.pluginus.net/image/i20230222134241.png -> https://share.pluginus.net/image/i20230222134511.png
but the problem is with the currency cache, currencies are kept in the cache all the time. - how do you check this?
Please check options - https://share.pluginus.net/image/i20240403124915.png and https://share.pluginus.net/image/i20240403125002.png
Hello
Please paste your license key here - https://share.pluginus.net/image/i20230222134241.png -> https://share.pluginus.net/image/i20230222134511.png
but the problem is with the currency cache, currencies are kept in the cache all the time. - how do you check this?
Please check options - https://share.pluginus.net/image/i20240403124915.png and https://share.pluginus.net/image/i20240403125002.png
Quote from Daxiorek on April 3, 2024, 12:06Unfortunately, I have it set this way, the currencies change by themselves and sometimes they don't even change
Unfortunately, I have it set this way, the currencies change by themselves and sometimes they don't even change
Quote from Pablo Borysenco on April 4, 2024, 16:26Hello
Please drop me wp-admin access - https://share.pluginus.net/image/i20230222134241.png ->https://share.pluginus.net/image/i20230222134615.png
$_SERVER['HTTP_X_GT_LANG'] - Are you sure that this variable returns these language codes? Perhaps the plugin uses this type of code: en_GB
Hello
Please drop me wp-admin access - https://share.pluginus.net/image/i20230222134241.png ->https://share.pluginus.net/image/i20230222134615.png
$_SERVER['HTTP_X_GT_LANG'] - Are you sure that this variable returns these language codes? Perhaps the plugin uses this type of code: en_GB