• Resolved stieranka

    (@stieranka)


    Hi,

    I need any WPML multi-currency function (hook), to switch price to country delivery.

    I use this code bellow to switch currency symbol when I change country delivery on checkout page. It is works fine, but this switch only currency symbol, not price. Does WPML have any hooks to change prices?

    add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
    function change_existing_currency_symbol( $currency_symbol, $currency ) {
      if ( ! is_admin() ) { 
        global $woocommerce;
        $my_country = $woocommerce->customer->get_shipping_country();
        if( $my_country == 'SK') {
            $currency_symbol = '€'; 
        } else {
            $currency_symbol = 'Kč'; 
        }
        return $currency_symbol;
      }
    }

    Regards,
    Steve

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi Steve,
    you can use this one https://wpml.org/wcml-hook/wcml_client_currency/ to switch currency in this case you don’t need hook which you used above

    Thread Starter stieranka

    (@stieranka)

    Hi Sergey,
    I’ve already tried it, but it do not work optimaly for me. After change country do not change product price (only delivery price), I must refresh page (F5), and then show.

    The solution for me would be to reload the page….

    Regards,
    Steve

    Plugin Contributor Andreas Panag

    (@andrewp-2)

    Hello Steve

    Can I ask you to paste the code you used for changing price so I can try to replicate your issue?

    Thank you very much.

    Thread Starter stieranka

    (@stieranka)

    Hi Sergey,

    this is code

    add_filter('wcml_client_currency', 'wcml_custom_currency');
    function wcml_custom_currency($current){
      if ( ! is_admin() ) { 
        global $woocommerce;
        $my_country = $woocommerce->customer->get_shipping_country();
        if( $my_country == 'SK') {
    	$new_currency = 'EUR'; 
        } else {
    	$new_currency = 'CZK'; 
        }
        return $new_currency;
      }
    }

    But I mayby switch to other plugin for change currency, becouse wcml not support coupons for fixed discount, only percentages :-/

    Steve

    sergey.r

    (@sergeyr-1)

    Hi Steve,
    sorry missed your reply.

    We loaded our MC hooks including wcml_client_currency hook only when front-end currency not equal to default one.

    Is it working to you with secondary currency?

    Thread Starter stieranka

    (@stieranka)

    Hi,
    I finally solved it in a different way. I linked the language to the currency, so if I switch the language in wpml, the currency is also switched. I do not distinguish the country of delivery. This is convenient.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to switch price to country delivery’ is closed to new replies.