Home Forums Pre-Sale Assistance Needed for Language and Currency Settings

Assistance Needed for Language and Currency Settings

  • Author
    Posts
  • #218392

    Hello,

    I hope this message finds you well. I am currently working on configuring language and currency settings on my WordPress site using the Gtranslate plugin and a woocommerce-multi-currency plugin.

    Requirements:
    Default Currency Based on Language:

    If the user selects English, the currency should default to USD.
    If the user selects Svenska (Swedish), the currency should default to SEK.
    For all other languages, the default currency should be EUR.
    User Flexibility:

    Users should have the option to switch the currency to EUR, even when the language is set to English. However, the initial view should still show USD by default.
    Current Setup:
    I have implemented session and cookie handling to manage these settings, but I am experiencing abnormal behavior with the currency switching. Here’s the code I am using for both sessions and cookies:

    Session Handling:

    add_action(‘init’, ‘check_and_set_language_currency_sessions’);
    function check_and_set_language_currency_sessions() {
    @session_start();

    $current_language = isset($_SERVER[‘HTTP_X_GT_LANG’]) ? $_SERVER[‘HTTP_X_GT_LANG’] : get_bloginfo(‘language’);
    $brab_current_language = isset($_SESSION[‘brab_current_language_’]) ? $_SESSION[‘brab_current_language_’] : ”;
    $brab_currency = isset($_SESSION[‘brab_currency_’]) ? $_SESSION[‘brab_currency_’] : ”;

    if (empty($brab_current_language)

You must be logged in to see replies to this topic. Click here to login or register