Skip to main content

Documentation Index

Fetch the complete documentation index at: https://discountkit.app/llms.txt

Use this file to discover all available pages before exploring further.

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.

How it works

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.

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
Expected from $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
Expected from $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.23,150.23, 15% of 0.27, etc.)
For typical retail prices (1010–500) and modest quantities, the difference is usually 0–1¢ per line and easy to miss.

How to get an exact total

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.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.38with101.38 with 10% off (0.138 → 0.14perpack)stillrounds,buttherelativeimpactattypicalquantitiesismuchsmallerthanperunitof0.14 per pack) still rounds, but the relative impact at typical quantities is much smaller than per-unit-of-0.23.
This rounding is applied by Shopify’s checkout, not by Discount Kit. The same per-unit allocation behaviour applies to native Shopify percentage discounts as well.