WOOCS - WooCommerce Currency Switcher Professional


WooCommerce Product Add-Ons Ultimate by pluginrepublic.com

Plugin link: https://pluginrepublic.com/wordpress-plugins/woocommerce-product-add-ons-ultimate/

  • In file plugins\product-extras-for-woocommerce\inc\functions-cart.php add next code:
    if (class_exists('WOOCS')) {
        global $WOOCS;
        if ($WOOCS->is_multiple_allowed) {
            $price = $WOOCS->woocs_exchange_value(floatval($price));
        }
    }

  • to the same file add next code:
    if (class_exists('WOOCS') AND $price) {
        global $WOOCS;
        if ($WOOCS->is_multiple_allowed) {
            $currrent = $WOOCS->current_currency;
            if ($currrent != $WOOCS->default_currency) {
                $currencies = $WOOCS->get_currencies();
                $rate = $currencies[$currrent]['rate'];
                $price = $price / $rate;
            }
        }
    }

  • to the same file add next code:
    if (class_exists('WOOCS')) {
        global $WOOCS;
        if ($WOOCS->is_multiple_allowed AND isset($cart_item_data['product_extras']['price_with_extras'])) {
            $currrent = $WOOCS->current_currency;
            if ($currrent != $WOOCS->default_currency) {
                $currencies = $WOOCS->get_currencies();
                $rate = $currencies[$currrent]['rate'];
                $cart_item_data['product_extras']['price_with_extras'] = $cart_item_data['product_extras']['price_with_extras'] / $rate;
            }
        }
    }

  • to the same file file add next code:
    if (class_exists('WOOCS')) {
        global $WOOCS;
        if ($WOOCS->is_multiple_allowed) {
            $currrent = $WOOCS->current_currency;
            if ($currrent != $WOOCS->default_currency) {
                $currencies = $WOOCS->get_currencies();
                $rate = $currencies[$currrent]['rate'];
                $cart_item_data['product_extras']['price_with_extras_discounted'] = $cart_item_data['product_extras']['price_with_extras_discounted'] / $rate;
            }
        }
    }

  • to the same file add next code:
    if (class_exists('WOOCS') AND $item['price']) {
        global $WOOCS;
    
        if ($WOOCS->is_multiple_allowed) {
            $currrent = $WOOCS->current_currency;
            if ($currrent != $WOOCS->default_currency) {
                $currencies = $WOOCS->get_currencies();
                $rate = $currencies[$currrent]['rate'];
                $item['price'] = $rate * $item['price'];
            }
        }
        $item['value'] = preg_replace('/\((.+)\)/', "", $item['value']);
    
    //$item['value'] .= sanitize_text_field("(" . wc_price($item['price']) .")");
    }

  • o your current child wp theme file functions.php add next code:
    function pewc_get_multicurrency_price($price, $item, $product) {
    
    // Compatibility with WooCommerce multilingual
        $price = apply_filters('wcml_raw_price_amount', $price);
    
        if (class_exists('WOOCS')) {
            global $WOOCS;
            if ($WOOCS->is_multiple_allowed) {
                $price = $WOOCS->woocs_exchange_value(floatval($price));
            }
        }
    
        return $price;
    }
    
    add_filter('pewc_filter_field_price', 'pewc_get_multicurrency_price', 10, 3);
    add_filter('pewc_filter_option_price', 'pewc_get_multicurrency_price', 10, 3);