FOX - Currency switcher and coupons
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 Brain2k on July 2, 2024, 13:14Hi dear sirs/madams.
I have FOX currency switcher installed - Version 1.4.1.9. Free version. I added 2 currencies, EUR and GBP.
My default currency in WooCommerce and in FOX currency switcher is EUR.
GBP conversion ratio is 0.84638
FOX currency switcher works fine if no coupons is applied.
The PROBLEM: If i apply a coupon, (which is created with Marketing -> Coupons), FOX currency switcher does not work correctly. Total sum is too low.
I am not using any 3rd party plugin for coupons, but i am using WooCommerce built in coupon functionality.
The prices in Woocommerce are in EUR. So base currency is EUR.
Steps to reproduce:
- Go to: https://bikerguard.com/product/test-product-1/?currency=GBP
Price is 100 EUR. Sale price is 20% off = 80 EUR. In GBP the sale price is around 67,71£ which is CORRECT.- Click "Buy now" to add the product to the cart
- Go to Cart. The total price is 67,71£ which is CORRECT. So without coupon applied it works fine.
- Now apply coupon "test123456". Coupon is set to 50% off the price. I added filter, which applies the coupon to "price" and not to "sale price". So new price should be 100 EUR - 50%= 50 EUR, converted to GBP should be around 42 GBP. Instead the price is around 35 GBP which is not correct.
- If you stay in the Cart and switch currency to EUR, the price is calculated correcttly = 50 EUR. Click: https://bikerguard.com/cart/?currency=eur
My coupon is set like this:
- Coupon code/name: test123456
- Discount type: Perentage discount
- Coupon amount: 50%
- Set for "Individual use only (the coupon cannot be used in conjunction with other coupons)
The only function i added, to apply the coupon to the "Price" and not to the"Sale price":
add_action( 'woocommerce_before_calculate_totals', 'before_calculate_totals', 10, 1);
function before_calculate_totals( $cart_object) {global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;$coupon = False;
if ($coupons = WC()->cart->get_applied_coupons() == False )
$coupon = False;
else {
foreach ( WC()->cart->get_applied_coupons() as $code ) {
$coupons1 = new WC_Coupon( $code );
if ($coupons1->type == 'percent_product' || $coupons1->type == 'percent')
$coupon = True;
}
}if ($coupon == True)
foreach ( $cart_object->get_cart() as $cart_item )
{
$price = $cart_item['data']->regular_price;
$cart_item['data']->set_price( $price );
}
}Can please anyone help me?
best regards,
Andrej
Hi dear sirs/madams.
I have FOX currency switcher installed - Version 1.4.1.9. Free version. I added 2 currencies, EUR and GBP.
My default currency in WooCommerce and in FOX currency switcher is EUR.
GBP conversion ratio is 0.84638
FOX currency switcher works fine if no coupons is applied.
The PROBLEM: If i apply a coupon, (which is created with Marketing -> Coupons), FOX currency switcher does not work correctly. Total sum is too low.
I am not using any 3rd party plugin for coupons, but i am using WooCommerce built in coupon functionality.
The prices in Woocommerce are in EUR. So base currency is EUR.
Steps to reproduce:
- Go to: https://bikerguard.com/product/test-product-1/?currency=GBP
Price is 100 EUR. Sale price is 20% off = 80 EUR. In GBP the sale price is around 67,71£ which is CORRECT. - Click"Buy now" to add the product to the cart
- Go to Cart. The total price is 67,71£ which is CORRECT. So without coupon applied it works fine.
- Now apply coupon"test123456". Coupon is set to 50% off the price. I added filter, which applies the coupon to"price" and not to"sale price". So new price should be 100 EUR - 50%= 50 EUR, converted to GBP should be around 42 GBP. Instead the price is around 35 GBP which is not correct.
- If you stay in the Cart and switch currency to EUR, the price is calculated correcttly = 50 EUR. Click: https://bikerguard.com/cart/?currency=eur
My coupon is set like this:
- Coupon code/name: test123456
- Discount type: Perentage discount
- Coupon amount: 50%
- Set for"Individual use only (the coupon cannot be used in conjunction with other coupons)
The only function i added, to apply the coupon to the"Price" and not to the"Sale price":
add_action( 'woocommerce_before_calculate_totals', 'before_calculate_totals', 10, 1);
function before_calculate_totals( $cart_object) {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
$coupon = False;
if ($coupons = WC()->cart->get_applied_coupons() == False )
$coupon = False;
else {
foreach ( WC()->cart->get_applied_coupons() as $code ) {
$coupons1 = new WC_Coupon( $code );
if ($coupons1->type == 'percent_product' || $coupons1->type == 'percent')
$coupon = True;
}
}
if ($coupon == True)
foreach ( $cart_object->get_cart() as $cart_item )
{
$price = $cart_item['data']->regular_price;
$cart_item['data']->set_price( $price );
}
}
Can please anyone help me?
best regards,
Andrej
Quote from Pablo Borysenco on July 3, 2024, 10:36Hello Andrej
Does everything work correctly without your custom code?
Hello Andrej
Does everything work correctly without your custom code?
Quote from Brain2k on July 3, 2024, 11:00Hi Pablo,
No, even if i remove/comment out my custom code, it does not work correctly.
And also in EUR everything works fine, even with coupon applied.
But if i change currency, it works fine without coupon, but when i apply coupon, it does not work correctly.
best regards.
Hi Pablo,
No, even if i remove/comment out my custom code, it does not work correctly.
And also in EUR everything works fine, even with coupon applied.
But if i change currency, it works fine without coupon, but when i apply coupon, it does not work correctly.
best regards.
Quote from Brain2k on July 3, 2024, 11:10Hi Pablo,
sorry yes if i remove custom code, it works fine.
I didn't noticed that before, sorry.
Now i have to find a way to apply coupon to base price not to sale price.
Sorry to bother you.
Andrej
Hi Pablo,
sorry yes if i remove custom code, it works fine.
I didn't noticed that before, sorry.
Now i have to find a way to apply coupon to base price not to sale price.
Sorry to bother you.
Andrej