I was able to recreate the problem on my test system (10cm = €1,10) by,
- Setting my thousand separator to ‘.’ and my decimal separator to ‘,’. (I am in the US, so they are reversed from your notation.)
- Using the notation above when I
[Set regular prices].
I was able to get correct results (10cm = €1,19) by using the ‘.’ as the decimal separator when I
[Set regular prices]. This is clearly a problem, and I wonder why I don’t hear about it more.
You can use this as a work-around until I figure out where the problem is. Leave your currency settings as they are, but use a period as the decimal separator when you use the
[Set regular prices] and
[Set sale prices] functions.
I will leave this thread open until I issue a fix.
Thanks for your quick reply. Now it works for me too.
I wouldn’t have thought of that with the point.
Please let me know when the problem is fixed.
I found that the problem was that I was using the PHP function
floatval(), which assumes a number with a dot as the decimal separator. The root cause may be a conflicting configuration between the server and WooCommerce (where the server locale may be something like ‘en_GB’), but I was unable to test for that.
Nonetheless, I fixed it. WooCommerce provides a couple of functions to localize number strings, and I am now using those throughout. The attribute pages also required this fix, since a markup of ‘+2,5%’ would save as ‘+2%’.
I will push out a new version of the code within the next couple of days, after I finish testing.
I have now found another problem. If I also enter a promotional price to the regular price, then the calculation is also not executed correctly.
With this example you can see it:
The regular price is €18.90 the promotion price is €9.50 for 1m
For 10cm, 20cm, 30cm…. no value is calculated at all and for +10cm, +20cm,… the value is too high.
This also does not work if I enter an offer price and then reduce it with, for example, 50%.
It works, I just forgot to check the box for Sale.
Since I haven’t pushed out the new code yet, I can set that check box as ‘on’ by default. (Which wouldn’t change anyone’s current settings; it would only apply to new installs).
I think that would be a good idea. Thanks for the quick implementation.
Is the new version then also compatible with the current and future WordPress version?
Yes. It will be out later today, and has been tested on the following.
Okay, the latest version is published. Please let me know what you think.
Perfect, everything works now. Also with “,”.