Skip to content
Docs
Available on the Shopify App Store

Percentage discount rounding

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.

For a line with quantity Q, unit price P, and percentage D%:

  1. Per-unit discount = P × (D / 100)
  2. Rounded to cents → call this r
  3. Total discount = r × Q
  4. Line total = (P × Q) − (r × Q)

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

  • 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

Expected from $46.00 × 0.90 would be $41.40 — a $0.60 difference, caused by the 0.3¢-per-unit rounding × 200 units.

  • 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

Expected from $69.00 × 0.85 would be $58.65 — a $1.35 difference, caused by the 0.45¢-per-unit rounding × 300 units.

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.23, 15% of $0.27, etc.)

For typical retail prices ($10–$500) and modest quantities, the difference is usually 0–1¢ per line and easy to miss.

If you need the discounted total to exactly match subtotal × (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.20 ($0.02 / unit) is exact at any quantity, but 10% off $0.23 is not.
  • Sell in larger units. A 6-pack at $1.38 with 10% off ($0.138 → $0.14 per pack) still rounds, but the relative impact at typical quantities is much smaller than per-unit-of-$0.23.