WooCommerce Multi-currency
This plugin will work only if you use button “Go to Cart/Checkout” or for mode Run at frontend.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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()); }); |