PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

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

woocommerce product addon with fox currency

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 please
If 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.
12

Hi support

On this site staging.tibladin.dk we also use woocommerce product addon, and we have tried adding your spcial code to the php, but the site fail. I think it's a wrong place we place your code, but couldn't find your suggest for code placement (we use newest woocommerce product addon version). Can you help where to place your code in the php

regards

Ole

Hello Ole

Ok! I added this to the adaptation queue

Hello Ole

Please do a test

Hi Pablo

I have tested but would it be possible to always round up ex 10 dkk should be 2 euro and not only 1 euro

where can i find the code for woocommerce product addon, so I can add it to live site

regards

Ole

Hello

Please try this - https://currency-switcher.com/hook/woocs_raw_woocommerce_price/

New  code:

In file wp-content\plugins\woocommerce-product-addons\includes\class-wc-product-addons-cart.php add next code:  https://share.pluginus.net/image/i20240531181742.png

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: https://share.pluginus.net/image/i20240531182106.png

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: -  https://share.pluginus.net/image/i20240603113834.png

$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: -  https://share.pluginus.net/image/i20240603113927.png

'woocs_is_multiple' => $woocs_is_multiple

In file wp-content\plugins\woocommerce-product-addons\assets\js\addons.js add next code: - https://share.pluginus.net/image/i20240531183303.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 AND woocs_current_currency['rate'] != undefined AND woocommerce_addons_params.woocs_is_multiple == 0) {
self.base_price  = self.base_price  * woocs_current_currency['rate'];
}
}
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'];
}
}

 

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

Hi Pablo

I have tried add this code to function.php, should it be the code for always round up? if so see this product https://staging.tibladin.dk/en/product/dish-in-green-30-cm-tamegroute-ceramic/ 10 dkk is still 1 euro (and not 2)

regards

Ole

Hi again Pablo

Can see you have added the code other thing that round up, I will try your links

regrads

Ole

Hello

10 dkk is still 1 euro (and not 2) - Try  to  enable  decimal  2 for EUR - https://share.pluginus.net/image/i20240603133958.png

Hi Pablo

I found two issue more in the product addons. the price is calculated correct now. but in the product text in SEK it say Ønsker du gaveindpakning?:

Ja tack (+ 23 SEK) (and calculated price is 15 SEK) and in euro it say (+ 0 euro) and calculated to 1

and in this link wp-content\plugins\woocommerce-product-addons\assets\js\addons.js add next code: it should be wp-content\plugins\woocommerce-product-addons\assets\js\frontend/addons.js add next code:

regards

Ole

Hello Ole

Ok!  I will  check it

Hello Ole

Ja tack (+ 23 SEK) (and calculated price is 15 SEK) and in euro it say (+ 0 euro) and calculated to 1 - Please drop me exact link to the issue(exact product)

https://tibladin.dk/sv/produkt/strandvaska-shopper-i-flatat-%C2%B7-vanilj/

regards

Ole

ok!  please  drop  me a  link  to the  issue  on  test site

https://staging.tibladin.dk/fr/produit/filet-au-crochet/  - I have tested this product and it seems to work correctly.

Hi Pablo

Can see the issue is solved now ??, I have tested 4 products and all is funtioning

thanks

Ole

Hello Ole

Great!  Welcome;)

Hi pablo

My customer have found one more small issue in product addon (minibasket/basket/checkuot is ok)

but in the product page there is a little issue, see

this (you can still use staging, but please tell me what to do on live site) 

Hello Ole

Ok! I will check  it

Hi Pablo

I think you have forget this small issue

regards

Ole

12