Quote from mrm051 on August 12, 2021, 19:34
Hello, Pablo!
Thank you for your reply.
I've just tested everything. The issue is not connected to a theme, other plugins or only RUB currency. Actually it affects any currencies except the default.
There is a little mistake in the code. The problem is present in free and paid version. You just forgot to backconvert substracted coupon amount from total amount.
In /classes/woocs.php
you backconvert total to the default currency (line 3932), but you don't backconvert the coupon discount (line 3937). So, then, when you substract coupon discount from total, the mistake appears. It's hard to notice that it's present in currencies with similar exchange rates. But you can see it when you get the currency with exchange rate which differs in hundred or ten times. I think you understand.
On line 3937 you have a mistake:
$total = $total - WC()->cart->get_discount_total();
Should be something like this instead:
$mrm051_discount = (float) $this->back_convert(WC()->cart->get_discount_total(), $currencies[$this->current_currency]['rate']); //mrm051 added this line
$total = $total - $mrm051_discount; //mrm051 added this line
So then when you check this expression it doesn't evaluate to true because the discount was substracted in rubles from dollars, so the total is wrong. Please, check the code from line 3928 to 3961.
if ($total >= $min_amount) {
$has_met_min_amount = true;
}
I hope you will fix it in the next versions. Have a nice day!
Hello, Pablo!
Thank you for your reply.
I've just tested everything. The issue is not connected to a theme, other plugins or only RUB currency. Actually it affects any currencies except the default.
There is a little mistake in the code. The problem is present in free and paid version. You just forgot to backconvert substracted coupon amount from total amount.
In /classes/woocs.php
you backconvert total to the default currency (line 3932), but you don't backconvert the coupon discount (line 3937). So, then, when you substract coupon discount from total, the mistake appears. It's hard to notice that it's present in currencies with similar exchange rates. But you can see it when you get the currency with exchange rate which differs in hundred or ten times. I think you understand.
On line 3937 you have a mistake:
$total = $total - WC()->cart->get_discount_total();
Should be something like this instead:
$mrm051_discount = (float) $this->back_convert(WC()->cart->get_discount_total(), $currencies[$this->current_currency]['rate']); //mrm051 added this line
$total = $total - $mrm051_discount; //mrm051 added this line
So then when you check this expression it doesn't evaluate to true because the discount was substracted in rubles from dollars, so the total is wrong. Please, check the code from line 3928 to 3961.
if ($total >= $min_amount) {
$has_met_min_amount = true;
}
I hope you will fix it in the next versions. Have a nice day!