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

Currency based on saved billing not working

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
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.

Hello,

Im trying to set up a currency switcher on a site im working on, i have a region switcher, custom coded into the site, that is changing the billing region in the cookie and its excluded from caching, Now i need the currency to also be based on the billing location, but this doesnt seem to be working..

I already saved the custom function as mentioned in your instructions, however, even though i changed the region on the frontend, i disabled wp-rocket, i checked all settings multiple times, the currency does not change when i cahnge the billing location.

The function i have:

// Override WOOCS country based on billing country and force currency change
add_action('woocommerce_customer_save_address', function($user_id, $load_address) {
global $WOOCS;

// Get billing country from WooCommerce
$billing_country = WC()->customer->get_billing_country();

if (!empty($billing_country)) {
// Set WOOCS to use billing country instead of GeoIP
$WOOCS->storage->set_val('woocs_user_country', $billing_country);

// Get and set currency based on billing country
$_currency = $WOOCS->get_currency_by_country($billing_country);
if ($_currency) {
$WOOCS->set_currency($_currency);
WC()->session->set('woocs_current_currency', $_currency); // Update session with new currency
}
}
}, 10, 2);

I hope you guys can help me out..

Hello

to switch currency - https://currency-switcher.com/function/woocs-set_currency

If this doesn't work then the problem is in your code.

Possible problem:

$billing_country  - This country code is missing from GEOIP settings

woocommerce_customer_save_address - This hook works late