Support » Plugin: Currency Switcher for WooCommerce » Change currency by language change

  • Hello,
    I need a little help with my page.
    I have google translate installed and active and your plugin.
    How can I create the possibility the currency to be changed by language switching?
    For example, when I choose English , the currency to be automatically switched to $, if I choose German, the currency to be switched to euro and etc.
    I tried this :
    https://currency-switcher.com/switch-currency-with-language-change/
    (I worked with the code for Gtranslate)
    Maybe it is not the correct article about the correct module?
    I guess I am not setting up some of the plugin settings right, too.
    Please , help !

Viewing 5 replies - 1 through 5 (of 5 total)
  • I saw my mistake.
    Wrong article.
    Now I checked this one: https://wpfactory.com/item/currency-switcher-woocommerce-wordpress-plugin/#languages
    And followed the steps, but still, it’s not working when switching languages.
    Can you, please, asssit?

    Maybe it doesn’t work with Gtranslate but with another language plugin?

    Tried with Polylang.
    Seems that it’s not working again or I am not doing something correctly.

    Switched do Gtranslate.
    Hope to hear from you soon with some sort of a solution .
    Thank you.

    Hello.
    Try this code.

    
    add_filter('wp_head', function() {
        $lang = isset($_SERVER['HTTP_X_GT_LANG']) ? $_SERVER['HTTP_X_GT_LANG'] : '';
        switch ($lang)
        {
            case 'en_GB':
                alg_wc_cs_session_set( 'alg_currency', EUR );
                break;
            default:
                alg_wc_cs_session_set( 'alg_currency', USD );
                break;
        }
    });
    

    But be sure to disable all sections related to currency selection in the plugin settings. Like set currency by locale or set currency by IP. You have to disable them to make this code work.

    • This reply was modified 2 months, 1 week ago by  fkoomek.
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.