Home Forums Plugins CURCY – WooCommerce Multi Currency Update Checkout Currency by functions.php

Update Checkout Currency by functions.php

  • Author
    Posts
  • #81152

    Jakub Kroutil
    Participant

    Hello,

    Useing your plugin
    WooCommerce Multi Currency – Currency Switcher – PRO
    I am facing problem with setting up condition for my case:

    When choosen:
    country: DK (Denmark)
    shipping: wf_woocommerce_shipping_pro:g1gls-express-parcell (GLS – EXPRESS PARCELL)
    payment method: bacs (BANK TRANSFER)

    I need to force checkout set the only one currency: EUR

    Just for above specific options.

    I have this code at functions.php my child theme:

    add_action(‘woocommerce_checkout_update_order_review’, ‘action_woocommerce_checkout_update_order_review’, 99 );
    function action_woocommerce_checkout_update_order_review($checkout)
    {
    $chosen_methods = WC()->session->get( ‘chosen_shipping_methods’ );
    $chosen_shipping = $chosen_methods[0];
    $chosen_payment_method = WC()->session->get(‘chosen_payment_method’);
    $country = WC()->customer->get_shipping_country();
    $currency = get_woocommerce_currency();

    if ( ($chosen_shipping == ‘wf_woocommerce_shipping_pro:g1gls-express-parcell’) AND ( $country == ‘DK’) AND ($chosen_payment_method == ‘bacs’)) {

    $data = new WOOMULTI_CURRENCY_Data();
    $data->set_current_currency( ‘EUR’, false );
    WC()->cart->calculate_totals();
    return;
    $data->reload_after_update_order_review();

    }

    It changes currency and do not let chose different currency.But once I refresh page manually.

    I tried:
    location.reload();
    <script type=”text/javascript”> jQuery(‘body’).trigger(‘update_checkout’); </script>

    But no luck for my code.

    You can check my site here https://slusny.net/en/

    Best Regards
    Jakub

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