Quote from khongyp on July 6, 2019, 02:43
Hi, I would like to have the delivery country change the currency and i have checked out your code here https://currency-switcher.com/possible-delivery-country-change-currency/ . But i need to add another condition that if the currency is CNY or WON then force it to SGD.
I have tried the following codes but the "if CNY or WON force to SGD" (highlighted in bold below) condition is not working. Could you please help to take a look? Thanks.
My Currency backend setting - Is Multiple Allowed (YES), GeoIP rules is on (CNY -> China, WON -> Korea, GBP -> UK, etc.), Checkout by Geo IP rules (NO),
How do i give you access to my backend? I don't think i can post it here.
add_action('woocommerce_checkout_update_order_review', function($data) {
global $WOOCS;
if (is_string($data)) {
parse_str($data, $data);
}
//***
$_currency = $WOOCS->get_currency_by_country($data['billing_country']);
$currt_currency = $WOOCS->current_currency;
if (!empty($_currency)) {
$WOOCS->set_currency($_currency);
}
if ($currt_currency == "CNY") {
$WOOCS->set_currency('SGD');
}
if ($currt_currency == "WON") {
$WOOCS->set_currency('SGD');
}
}, 9999);
Hi, I would like to have the delivery country change the currency and i have checked out your code here https://currency-switcher.com/possible-delivery-country-change-currency/ . But i need to add another condition that if the currency is CNY or WON then force it to SGD.
I have tried the following codes but the"if CNY or WON force to SGD" (highlighted in bold below) condition is not working. Could you please help to take a look? Thanks.
My Currency backend setting - Is Multiple Allowed (YES), GeoIP rules is on (CNY -> China, WON -> Korea, GBP -> UK, etc.), Checkout by Geo IP rules (NO),
How do i give you access to my backend? I don't think i can post it here.
add_action('woocommerce_checkout_update_order_review', function($data) {
global $WOOCS;
if (is_string($data)) {
parse_str($data, $data);
}
//***
$_currency = $WOOCS->get_currency_by_country($data['billing_country']);
$currt_currency = $WOOCS->current_currency;
if (!empty($_currency)) {
$WOOCS->set_currency($_currency);
}
if ($currt_currency =="CNY") {
$WOOCS->set_currency('SGD');
}
if ($currt_currency =="WON") {
$WOOCS->set_currency('SGD');
}
}, 9999);