If a percentage discount produces a total that’s a few cents — or sometimes a few dollars — off what you’d expect, the cause is almost always per-unit rounding. Shopify calculates percentage discounts on a per-unit basis, rounds the result to the currency’s smallest denomination (one cent for USD), and then multiplies by the line quantity. When the discount per unit doesn’t divide evenly into cents, that rounding compounds with quantity.Documentation Index
Fetch the complete documentation index at: https://discountkit.app/llms.txt
Use this file to discover all available pages before exploring further.
How it works
For a line with quantityQ, unit price P, and percentage D%:
- Per-unit discount =
P × (D / 100) - Rounded to cents → call this
r - Total discount =
r × Q - Line total =
(P × Q) − (r × Q)
P × (D / 100) is already a clean number of cents, the result matches the “naive” subtotal × D% calculation exactly. Otherwise, the per-unit rounding gets multiplied by Q, so larger quantities make the gap more visible.
Worked examples
10% off 200 × $0.23
- Per-unit discount:
$0.23 × 0.10 = $0.023→ rounds to $0.02 / unit - Total discount:
200 × $0.02 = $4.00 - Line total:
$46.00 − $4.00 = $42.00
$46.00 × 0.90 would be $41.40 — a $0.60 difference, caused by the 0.3¢-per-unit rounding × 200 units.
15% off 300 × $0.23
- Per-unit discount:
$0.23 × 0.15 = $0.0345→ rounds to $0.03 / unit - Total discount:
300 × $0.03 = $9.00 - Line total:
$69.00 − $9.00 = $60.00
$69.00 × 0.85 would be $58.65 — a $1.35 difference, caused by the 0.45¢-per-unit rounding × 300 units.
When you’ll notice it
The gap is most visible when:- The unit price is low (cents and tens-of-cents)
- The quantity is high
- The percentage produces a sub-cent fraction per unit (10% of 0.27, etc.)
How to get an exact total
If you need the discounted total to exactly matchsubtotal × (1 − D%):
- Use a fixed amount discount instead of a percentage. A fixed amount is applied to the line as a whole rather than per unit.
- Choose a unit price and percentage that divide cleanly into cents. For example, 10% off 0.02 / unit) is exact at any quantity, but 10% off $0.23 is not.
- Sell in larger units. A 6-pack at 0.138 → 0.23.