Currency Switcher conversion problem with Woocommerce product add-ons plugin
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page pleaseIf you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.
Quote from mdelauzun_400s41u8 on October 5, 2019, 05:33Hi,
I installed the Currency switcher and added the additional code for the compatibility with "Product Add-Ons (by WooCommerce)" from https://currency-switcher.com/codex/
Unfortunately there is still a bug. The conversion is not working on the drop-down menu of my add-ons. By example an add-on is 22 EUR, it will be "converted" as $22. However when the customer select the add-ons, the total is converted to 24.14$ which is the correct price.
Unfortunately this forum doesn't allow me to add a screenshot via this message. But you can check it here: https://www.mariondelauzun.com/product/custom-pet-portrait-street-art/
Thank you!
Marion
Hi,
I installed the Currency switcher and added the additional code for the compatibility with"Product Add-Ons (by WooCommerce)" from https://currency-switcher.com/codex/
Unfortunately there is still a bug. The conversion is not working on the drop-down menu of my add-ons. By example an add-on is 22 EUR, it will be"converted" as $22. However when the customer select the add-ons, the total is converted to 24.14$ which is the correct price.
Unfortunately this forum doesn't allow me to add a screenshot via this message. But you can check it here: https://www.mariondelauzun.com/product/custom-pet-portrait-street-art/
Thank you!
Marion
Quote from Pablo Borysenco on October 7, 2019, 13:04Hello Marion
Please try this code:
1)In file \plugins\woocommerce-product-addons\includes\class-product-addon-cart.php add next code ( https://c2n.me/40HWQrb.png ):
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’];
//$price = $price / $rate;
}
}
}AND add this code ( https://c2n.me/40HWTkd.png )
$price_temp = $addon[‘price’];
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’];
$price_temp = $price_temp * $rate;
}
}AND change code ( https://c2n.me/40HWWsK.png )
VIDEO – https://c2n.me/40Bz0xc
if ( $addon[‘price’] && ‘percentage_based’ !== $price_type && 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 ;
}
}2) In file \wp-content\plugins\woocommerce-product-addons\includes\class-product-addon-display.php add code ( https://c2n.me/40HX0Wb.png )
$suffix = “”; //woocs fix
$woocs_is_multiple = 0;
if (class_exists(‘WOOCS’)) {
global $WOOCS;
$woocs_is_multiple = $WOOCS->is_multiple_allowed;
}AND add code ( https://c2n.me/40HX3WA.png )
‘woocs_is_multiple’ => $woocs_is_multiple,
3) in file plugins\woocommerce-product-addons\assets\js\addons.js add code ( https://c2n.me/40HX7ax.png )
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) {
product_price = product_price * woocs_current_currency[‘rate’];
}
}AND add this code ( https://c2n.me/40HX974.png )
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’];
}
}4) In functions.php add code ( https://c2n.me/40HXbmR.png )
add_filter(‘woocommerce_product_addons_option_price’, ‘woocs_compatib_woopd’, 99990, 4);
add_filter(‘woocommerce_product_addons_price’, ‘woocs_compatib_woopd’, 99990, 4);function woocs_compatib_woopd($price, $option, $i, $type) {
if ($option[‘price’] > 0 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’];
$price = ‘(‘ . wc_price( WC_Product_Addons_Helper::get_product_addon_price_for_display($option[‘price’] * $rate)) . ‘)’;
}
}
return $price;
}
Hello Marion
Please try this code:
1)In file \plugins\woocommerce-product-addons\includes\class-product-addon-cart.php add next code ( https://c2n.me/40HWQrb.png ):
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’];
//$price = $price / $rate;
}
}
}
AND add this code ( https://c2n.me/40HWTkd.png )
$price_temp = $addon[‘price’];
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’];
$price_temp = $price_temp * $rate;
}
}
AND change code ( https://c2n.me/40HWWsK.png )
VIDEO – https://c2n.me/40Bz0xc
if ( $addon[‘price’] && ‘percentage_based’ !== $price_type && 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 ;
}
}
2) In file \wp-content\plugins\woocommerce-product-addons\includes\class-product-addon-display.php add code ( https://c2n.me/40HX0Wb.png )
$suffix = “”; //woocs fix
$woocs_is_multiple = 0;
if (class_exists(‘WOOCS’)) {
global $WOOCS;
$woocs_is_multiple = $WOOCS->is_multiple_allowed;
}
AND add code ( https://c2n.me/40HX3WA.png )
‘woocs_is_multiple’ => $woocs_is_multiple,
3) in file plugins\woocommerce-product-addons\assets\js\addons.js add code ( https://c2n.me/40HX7ax.png )
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) {
product_price = product_price * woocs_current_currency[‘rate’];
}
}
AND add this code ( https://c2n.me/40HX974.png )
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’];
}
}
4) In functions.php add code ( https://c2n.me/40HXbmR.png )
add_filter(‘woocommerce_product_addons_option_price’, ‘woocs_compatib_woopd’, 99990, 4);
add_filter(‘woocommerce_product_addons_price’, ‘woocs_compatib_woopd’, 99990, 4);
function woocs_compatib_woopd($price, $option, $i, $type) {
if ($option[‘price’] > 0 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’];
$price = ‘(‘ . wc_price( WC_Product_Addons_Helper::get_product_addon_price_for_display($option[‘price’] * $rate)) . ‘)’;
}
}
return $price;
}