• Resolved koertyj

    (@koertyj)


    I have entered the markup and markdown in percent for all attributes. e.g. -10cm -90%, +10cm +10%. It should then work with this product (it does not work with the others either. For one of them I entered the prices manually) the price for 1m should be 11.90 and for e.g. 10cm 1.19. But the last decimal place is always rounded down. What is the problem here and how can I change the price?

    Thanks and best regards,
    Jürgen

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Mark Tomlinson

    (@marktomlinson)

    I was able to recreate the problem on my test system (10cm = €1,10) by,

    1. Setting my thousand separator to ‘.’ and my decimal separator to ‘,’. (I am in the US, so they are reversed from your notation.)
    2. 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.

    Thread Starter koertyj

    (@koertyj)

    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.

    Plugin Author Mark Tomlinson

    (@marktomlinson)

    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.

    Thread Starter koertyj

    (@koertyj)

    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:
    https://to-stoffe.jk-design.at/produkt/baumwollelasthan/

    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%.

    Thread Starter koertyj

    (@koertyj)

    It works, I just forgot to check the box for Sale.

    Plugin Author Mark Tomlinson

    (@marktomlinson)

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

    Thread Starter koertyj

    (@koertyj)

    I think that would be a good idea. Thanks for the quick implementation.

    Thread Starter koertyj

    (@koertyj)

    Is the new version then also compatible with the current and future WordPress version?

    Plugin Author Mark Tomlinson

    (@marktomlinson)

    Yes. It will be out later today, and has been tested on the following.

    WordPress: 6.1
    PHP: 8.1.2
    WooCommerce: 7.1.0
    Apache: 2.4.52
    MySQL: 8.0.31

    Plugin Author Mark Tomlinson

    (@marktomlinson)

    Okay, the latest version is published. Please let me know what you think.
    ??

    Thread Starter koertyj

    (@koertyj)

    Perfect, everything works now. Also with “,”.

    Plugin Author Mark Tomlinson

    (@marktomlinson)

    ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Rounding problem in price calculation’ is closed to new replies.