WooCommerce Product Add-Ons (by WooCommerce)
- Into file wp-content\plugins\woocommerce-product-addons\includes\class-wc-product-addons-cart.php add next code:
if ($addon['price'] 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; } }
- Also in the same file add code:
if (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; }
- On the same file add also:
'woocs_is_multiple' => $woocs_is_multiple
- In file wp-content\plugins\woocommerce-product-addons\assets\js\frontend/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 && woocs_current_currency['rate'] != undefined && woocommerce_addons_params.woocs_is_multiple == 0) { self.base_price = self.base_price * woocs_current_currency['rate']; } }
- Also on the same file add 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 && woocs_current_currency['rate'] != undefined && 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']; } }
- and into file functions.php of the current WordPress theme add next code:
add_filter('woocommerce_product_addons_option_price', function ($price_html, $option, $i, $type) { if ($price_html AND class_exists('WOOCS')) { global $WOOCS; $option_price = !empty($option['price']) ? $option['price'] : ''; $option_price_type = !empty($option['price_type']) ? $option['price_type'] : ''; $price_prefix = 0 < $option_price ? '+' : ''; $price_type = $option_price_type; $price_raw = apply_filters('woocommerce_product_addons_option_price_raw', $option_price, $option); $price_raw = $WOOCS->woocs_exchange_value($price_raw); $price_html = '(' . $price_prefix . wc_price(WC_Product_Addons_Helper::get_product_addon_price_for_display($price_raw)) . ')'; } return $price_html; }, 20, 4);
This edit is inside another plugin's file, so a plugin update will undo it. Write the change down, and re-apply it after every update of that plugin — or ask its authors to include the fix on their side, which is the only version that survives. If the change is inside FOX itself, tell us: a fix that has to be re-applied by hand is a bug on our side, not a solution.