WOOCS - WooCommerce Currency Switcher

UPS Shipping Method by WooCommerce

Plugin URL: https://woocommerce.com/products/ups-shipping-method/

  • to your current child wp theme file functions.php add next code:
    add_filter('woocommerce_shipping_ups_check_store_currency', function ($alow, $currency, $xml, $_this) {
        return false;
    }, 99, 4);
    
    add_filter('woocommerce_shipping_ups_rate', function ($data, $currency, $xml, $_this) {
    
        if (class_exists('WOOCS')) {
            global $WOOCS;
            if ($WOOCS->is_multiple_allowed) {
                $current = $WOOCS->current_currency;
                $currencies = $WOOCS->get_currencies();
                $def_currency = $WOOCS->default_currency;
                if ($current != $currency && isset($currencies[$currency])) {
                    $rate = $currencies[$currency]['rate'];
                    $data['cost'] = $data['cost'] / $rate;
                    $data['cost'] = $WOOCS->woocs_exchange_value(floatval($data['cost']));
                }
            }
        }
    
        return $data;
    }, 99, 4);