Switch currency with language change
WPML:
- open functions.php of your current wp theme
- drop there next PHP code:
add_filter('wp_head', function() { $lang = ICL_LANGUAGE_CODE; global $WOOCS; switch ($lang) { case 'bg': $WOOCS->set_currency('BGN'); break; case 'en': $WOOCS->set_currency('EUR'); break; default: $WOOCS->set_currency('USD'); break; } });
- See WPML docs about languages codes
Polylang and TranslatePress:
- open functions.php of your current wp theme
- drop there next PHP code:
add_filter('wp_head', function() { $lang = get_locale(); global $WOOCS; switch ($lang) { case 'bg_BG': $WOOCS->set_currency('BGN'); break; case 'en_GB': $WOOCS->set_currency('EUR'); break; default: $WOOCS->set_currency('USD'); break; } });
- https://wordpress.org/support/topic/switch-currency-with-language-change-polylang/
- See Polylang docs about languages codes
GTranslate:
- open functions.php of your current wp theme
- drop there next PHP code:
add_filter('wp_head', function() { $lang = isset($_SERVER['HTTP_X_GT_LANG']) ? $_SERVER['HTTP_X_GT_LANG'] : ''; global $WOOCS; switch ($lang) { case 'bg_BG': $WOOCS->set_currency('BGN'); break; case 'en_GB': $WOOCS->set_currency('EUR'); break; default: $WOOCS->set_currency('USD'); break; } });
- https://wordpress.org/plugins/gtranslate/
qTranslate X integration:
- open functions.php of your current wp theme
- drop there next PHP code:
add_action('wp_head', function () { if (function_exists('qtranxf_getLanguage') AND class_exists('WOOCS')) { $lang = qtranxf_getLanguage(); global $WOOCS; switch ($lang) { case 'bg': $WOOCS->set_currency('BGN'); break; case 'en': $WOOCS->set_currency('EUR'); break; default: $WOOCS->set_currency('USD'); break; } } });