I think there is a rounding issue in your order edit API. I don’t understand why $3.6125 is rounding to $3.62. The first item $2.5 * 0.85 = $2.125 and it’s rounding to $2.13
What you’re seeing is expected behaviour due to how Shopify’s system uses and calculates discounts, and not necessarily because of order editing. I believe you commented on this forum post where this comment elicits this. Actual discounts are rounded down to 2 d.p. Hence the reason you see 3.62 instead of 3.61 which you expect.
Using the example provided you provided, 15% off 4.25 is 0.6375, which when rounded down to 2 d.p. becomes 0.63. 4.25 - 0.63 = 3.62
Hope this clears things up for you. If there are reasons why how we calculate discounts affect your business, please do share, and I’ll make sure to pass that along to the appropriate team.
I just noticed the same problem with my 10% member discount. The item was priced at $6.98, so the discount should be .70, not .69 like Shopify calculated. Interesting enough, it had .70 at first and then changed it to .69! I suggest you folks read up on basic math principles for rounding.
Hi all, just encountered the same kind of issue when importing markdown sales from eBay in to my Shopify store (Supply theme ). Item prices are all correct - as entered into Bulk Editor, however some of the percent discounts displayed are incorrect, (by 1%) due to incorrect rounding … perhaps a minor thing, but very frustrating !
I am displaying the percentage saved on a sale price, (involves a slight tweak to the price-sale.liquid snippet). The actual discounted prices are all correct, however Shopify will round DOWN all percentages to display the next lower integer . Since there is a small degree of normal rounding in all calculations, when re-quoting actual sale prices a 15% discount might translate to 14.97% or 15.03% . But Shopify will display a calculated 14.97% as "SAVE 14% (incorrect), and 15.03% as "SAVE 15% (correct). This gives a messy and inconsistent look to my collection pages.
Simply truncating or cutting off the decimal places is not the usual definition of rounding. In addition using the math filter “round” didn’t fix the problem either, so I figured that the auto rounding function must be built in to some other file. I searched the forum pages for any help on this, but couldn’t find much. So, although a newbie to Liquid, I set about figuring out a work-around, for where Shopify was dropping the displayed discount by 1% (5% was showing as 4%, 15% as 14% etc, ) .
I came up with the following if / elsif matrix, which is fairly straight forward and works for me, and something similar might work for anyone finding a similar issue,
{% assign discount_percent = compare_price | minus: product_price | times: 100 | divided_by: compare_price %}
{% if discount_percent >= 4 and discount_percent < 5 %}
{% assign result = discount_percent %}
{{ result | plus: 1 }}%
{% elsif discount_percent >= 5 and discount_percent < 14 %}
{% assign result = discount_percent %}
{{ result | plus: 0 }}%
{% elsif discount_percent >= 14 and discount_percent < 15 %}
{% assign result = discount_percent %}
{{ result | plus: 1 }}%
{% elsif discount_percent >= 15 and discount_percent < 24 %}
{% assign result = discount_percent %}
{{ result | plus: 0 }}%
{% elsif discount_percent >= 24 and discount_percent < 25 %}
{% assign result = discount_percent %}
{{ result | plus: 1 }}%
{% elsif discount_percent >= 25 %}
{% assign result = discount_percent %}
{{ result | plus: 0 }}%
{% endif %}
Hi @syf_1 , this way of rounding is affecting my business too, I agree with all the other users.
In your example discount is 0.64 as you have a 7 in the 3 d.p. (below 5 and above 5 is the discriminant). Besides the issue with giving the customer less discount, this also affect my accounting as when we insert order in our system that calculates the discount correctly, there is alwas a 1p difference for each item sold. It is very annoying and requires accounting procedures to fix the discrepancy, even if it is just 1p
I came across this thread looking for a solution to an incorrect percentage off being displayed on the site. Figured I’d post the solution I ended up using.
The trick was to remove the rounding from Shopify and take care of it myself. The part that does this is times: 1.0. Then at the end I round and then take the absolute value (drops all decimal places off)
I see what you are saying but this is still incorrect. 15% off of $4.25 is 0.6375. Because the 7 is f and above (basic math) your amount off should be 0.64. This is a constant issue on Shopify which means as orders are moved into our offline operating systems they are constantly having to be adjusted.