WOOCS - WooCommerce Currency Switcher Professional


WooCommerce Product Add-Ons (by WooCommerce)

The Plugin URL: https://woocommerce.com/products/product-add-ons/

  • In file wp-content\plugins\woocommerce-product-addons\includes\class-wc-product-addons-cart.php add next code:
    if ($addon['price'] AND 'percentage_based' !== $addon['price_type'] AND class_exists('WOOCS')) {
        global $WOOCS;
        $currrent = $WOOCS->current_currency;
        if ($currrent != $WOOCS->default_currency AND $WOOCS->is_multiple_allowed) {
            $currencies = $WOOCS->get_currencies();
            $rate = $currencies[$currrent]['rate'];
            $addon['price'] = $addon['price'] * $rate;
        }
    }
    

  • In file wp-content\plugins\woocommerce-product-addons\includes\class-wc-product-addons-display.php add next code:
    $suffix = ''; //woocs fix
    $woocs_is_multiple = 0;
    if (class_exists('WOOCS')) {
        global $WOOCS;
        $woocs_is_multiple = $WOOCS->is_multiple_allowed;
    }
    

  • And on the same file add code:
    'woocs_is_multiple' => $woocs_is_multiple

  • In file wp-content\plugins\woocommerce-product-addons\assets\js\addons.js add next code:
    var woocs_exists = true;
    
    try {
        if (woocs_current_currency)
            woocs_exists = true;
    } catch (e) {
        woocs_exists = false;
    }
    
    if (woocs_exists) {
        if (woocs_current_currency != undefined AND woocs_current_currency['rate'] != undefined AND woocommerce_addons_params.woocs_is_multiple == 0) {
            product_price = product_price * woocs_current_currency['rate'];
        }
    }
    

  • And on the same file:
    var woocs_exists = true;
    
    try {
        if (woocs_current_currency)
            woocs_exists = true;
    } catch (e) {
        woocs_exists = false;
    }
    
    if (woocs_exists) {
        if (woocs_current_currency != undefined AND woocs_current_currency['rate'] != undefined AND addon_cost != undefined) {
            addon_data.cost = addon_data.cost * woocs_current_currency['rate'];
            addon_data.cost_raw = addon_data.cost_raw * woocs_current_currency['rate'];
        }
    }