Support

Content of the article

You need to log-in to create request (topic) to the support

Incompatibility with WooCommerce Product Add-Ons

(new from 01-07-2019)

Hi, thanks for your free plugin.  I've been using it on my site and it's been great.  However, I just added the WooCommerce Product Add-Ons, which allows me to list prices for additional options on my product pages.  The problem now is, when I convert from my base currency to the US $ currency, the sign of the new price changes to $ without converting the figure.  So, N5000 becomes $5000!  And this is added up with the converted price of the product, from say N36000 to $100.  So,

N36000 + N5000 = N41000

When converted, you get

$100 + $5000 = $5100!

Even though this is bad, the actual figure in the Cart page is N41,000 converted to $, and it is correct.  But the problem is that the [product add-on price is still shown to be $5000, even at the checkout!

Is this something you can help me resolve pls?  If I have to upgrade, I'm willing to pay for the upgrade of the plugin, if this issue would be worked upon.  I've reached out to Automatic about their WooCommerce Product Add-On plugin concerning this issue, and they said to check with you, since it's your plugin that does the conversion.

Sincerely, Ufuoma.

Hello Ufuoma.

Please  try:

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 )

 

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;
}

Hi Pablo,

Your feedback is really great.  At least I know that the issue can be corrected with some coding.  Well, I actually don't code, I use Wordpress themes and plugins.  I would like to upgrade to the paid version of your plugin, but I just need to know that the compatibility issue will be taken care of.  Would you be able to help me resolve the issue, if I give you the right access to test the site?  I'd appreciate your feedback, thanks!

Sincerely, Ufuoma.

Hi Pablo,

I've paid for the upgrade now and installed it at https://elvirajude.com.  I am using percentages (instead of exact amounts) to manage the conflict with the product add-ons, but it isn't really the best.  I would still appreciate your help to improve the compatibility of this plugin with the WooCommerce Product Add-ons, so that the site can function optimally.  Thanks for the plugin and the support!

Sincerely, Ufuoma.

Hello

Unfortunately, this code is the best that I can provide for compatibility.

If you have no programming experience, you should hire a developer.

Hi Pablo,

I'm using the plugin editor to edit the sections you suggested, and to add the new code.  However, there's an issue with the 3rd item on your list.  The image you sent and the code you gave do not match.  Also, the system is showing an error message when I try to input the code, saying "Unexpected token ILLEGAL".

Please can you help me double check what you've sent for errors, and let me know the correct code to place and where?  I am grateful.

Sincerely, Ufuoma.

Hello Ufuoma

the screenshot shows the place where to insert the code.

You  can drop me  files, I will check  it.

 

Hi Pablo,

Thanks for your quick response.

I've uploaded two screenshots of the same screen here:

 

The screenshot below shows the errors

In the screenshot you sent me, there is no

var woocs_exists = true;
try {
if (woocs_current_currency)
woocs_exists = true;
} catch(e) { woocs_exists = false; }
if (woocs_exists){

There is only

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’];
}

Check it here:

https://c2n.me/40HX7ax.png

I appreciate your help with this.

Hello

it looks like the text was formatted.

To  fix it - try to change  these  symbols  to standard quotes :

In the screenshot you sent me, there is no - The screenshot shows the place where to insert. But paste the code I gave you in a text message

That removed the error messages, thanks.  However, the screenshots still don't match, though I understand you were showing me where to place the code.  In the other screenshots, when I placed the code, it matched the numbering and placement you sent.  But thanks, I'll keep putting in the rest of the code.

I do have a question though.  What happens when I update these plugins that I've edited?  Won't the update override these changes I've made manually?  Will I have to put the code back after every update on the plugins affected?

I appreciate your feedback.

Sincerely, Ufuoma.

I've finished putting the code in the staging site, but it didn't work (the figures didn't convert when I changed currency).  Also, I lost some old functionality of the product add-on plugin, such that I can no longer select the colour or size I want.

Is there any other way you can assist, please?

Sincerely, Ufuoma.

Hello Ufuoma.

Won't the update override these changes I've made manually?  -   Unfortunately, after each update of the plugin, you need to repeat it.

If you can't insert the code, you should hire a developer.