This plugin will work only if you use button "Go to Cart/Checkout" or for mode Run at frontend
add_action("wpo_before_switch_customer_apply_cart_data", function ($cart) {
if ( ! class_exists('\WOOMC\MultiCurrency\App') ) {
return;
}
$current_user = \WOOMC\MultiCurrency\App::instance()->getUser();
$country = '';
if ( isset($cart['customer']['billing_country']) && $cart['customer']['billing_country'] ) {
$country = $cart['customer']['billing_country'];
}
if ( ! $country ) {
$country = get_user_meta(get_current_user_id(), 'billing_country', true);
}
if ( ! $country ) {
return;
}
$current_user->set_country($country);
$country_obj = new \WOOMC\MultiCurrency\Country($country);
$current_user->set_currency($country_obj->getCurrency());
});