Hi @mikemfsg,
Could you please provide me with some samples on how to replicate this issue? I tried applying the Store Credit with decimal value with less than the order value and it works fine for me. https://snipboard.io/psotcQ.jpg
Hello,
To replicate this issue is not that easy.
You must have added and removed store credits to an user to finally get this issue.
As a matter of fact, the following sequence did the trick for me:
From a brand new client, with no store credit: +5.01, +5, -10.01, +4.99, +0.02, +0.03, +5.03, -0.6 .
This way, user gets 9.47 store credits.
In this case, the user can’t redeem 9.47 credits. But 9.46 is ok, so is 9.469…
That is because of float limitations (read this).
I did some debug and here is the results I got: screenshot of notification.
You can see there that $amount - $balance equals MINUS ZERO dot zero (-0.000000), and not just ZERO (0.000000). This demonstrates that $amount is considered greater than $balance… On the contrary, $balance - $amount equals 0.000000 !
Knowing that, the best I could achieve seems to be changing this line into : if ($amount < 0 || round($amount, 2) > round($balance, 2) ) { as exposed in https://www.php.net/manual/en/language.types.float.php .
Hope it helps.
Note that this may solve the “wrong” notification issue by allowing the user to set the good amount, but it will note solve other undergoing calculation precision issues.
Hi @madmax4ever,
Thanks for your further explanation.
I’ve raised this to our dev team to fix in the upcoming update of Advanced Coupons for WooCommerce plugin. 🙂