PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Unable to set currency with ship to different address code

This support system is for all types of the plugins as for premium versions, so for free ones! If you have premium version do not forget in the private data of the request (!!not in the text of the support request!!) after its publishing insert purchase code please (see blue-green button on the right side) and press Save button.
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi,

The issue I am facing is as follows -

If I use the below code only, then the currency is changing correctly based on the billing address:

add_action('woocommerce_checkout_update_order_review', function($data) {
global $WOOCS;

if (is_string($data)) {
parse_str($data, $data);
}

$country = $data['billing_country'];
$_currency = $WOOCS->get_currency_by_country($country);
if (!empty($_currency)) {
$WOOCS->set_currency($_currency);
}
}, 9999);

 

However, since I have to change the currency if someone opts to change their shipping country, then I am using the below code as suggested by you to someone else in another topic on this forum -

add_action('woocommerce_checkout_update_order_review', function($data) {
global $WOOCS;

if (is_string($data)) {
parse_str($data, $data);
}

$country = $data['billing_country'];

if(isset($data['shipping_country']) AND $data['shipping_country'] AND !wc_ship_to_billing_address_only()){
$country = $data['shipping_country'];
}
$_currency = $WOOCS->get_currency_by_country($country);
if (!empty($_currency)) {
$WOOCS->set_currency($_currency);
}
}, 9999);

 

With this code, it is changing according to shipping country only whereas I would want it both ways. Please help.

Site link - https://bit.ly/3EqrGpl

2 currencies are used on this site - INR for India and USD for everywhere else

Hello

Please  delete  this code   - https://share.stackovergo.com/image/i20211029115041.png -  and  do a  test

Hi Pablo,

Thank you for your response earlier.

Sorry I could not respond as I got unwell for quite sometime now.

I am back at work now. I checked by removing this code. The situation remained the same.

Please guide how can we fix it now?

Hello

Please  drop  me exact  link to the  issue

Site link - https://bit.ly/3EqrGpl

Hi,

Did you check?

I have currently kept this code in the comments so that the users are not affected -

if(isset($data['shipping_country']) AND $data['shipping_country']){
$country = $data['shipping_country'];
}

Hello

Please paste your license key here - https://share.stackovergo.com/image/i20210618130558.png -> https://share.stackovergo.com/image/i20210618130614.png and  wp-admin access - https://share.stackovergo.com/image/i20210618130637.png

Hi,

We are currently on a free version and facing these issues.

Hello

We are currently on a free version and facing these issues. - This is not true. I see that you are using the paid version of the plugin.

And this is not a plugin problem, this is a custom code problem that you inserted.

 

Hi,

The custom code was provided by you to someone in this forum only. Also, you had asked me to remove that line of code to check. Request you to please see our initial conversation regarding this in this thread and help me.

Hello

Please paste your license key here - https://share.stackovergo.com/image/i20210618130558.png -> https://share.stackovergo.com/image/i20210618130614.png