Discount Codes Are Killing Your Shopify Margin (Fix Guide)

A Shopify merchant we worked with ran a 30% off sitewide promo last Black Friday, layered a 10% newsletter code on top, threw in free shipping, and celebrated record revenue. Three weeks later the accountant called: roughly 40% of those orders had shipped at a loss. This article is about why that happens and how to stop it.

The Discount Stacking Problem

On most Shopify stores, a single order can quietly accumulate four or five separate discounts: a site-wide sale percentage, a coupon code the customer entered at checkout, an automatic discount triggered by cart value, a free shipping promotion, and sometimes a loyalty rewards credit. The customer sees one final price. The merchant sees one line on the order. Nobody sees the layered economics underneath.

The trouble is that each discount is calculated against the already-discounted subtotal in some cases, but as a percentage of the original price in others, depending on how it was configured. Combined with the fact that payment fees are charged on the gross-of-discount but before-tax amount, the maths gets messy fast. If you have never sat down and worked through how to calculate true profit on a Shopify order, the stacking effect is invisible.

Worked Example: How Margin Disappears

Take a $100 product with a $40 landed cost. Margin before any discounts looks healthy.

Real profit on this order: $63 minus $9 minus $2.13 minus $40 equals $11.87. Margin: 18.8%. Still positive, but you have walked from a healthy 50%+ margin down into a single-digit zone after a quick post-purchase return rate of 10%.

Now run the same example with a $50 product carrying $25 COGS, or with the customer paying through an international card (1.5% surcharge on top of standard fees). The order goes negative. We break down exactly how the gateway maths work in our guide to Shopify payment fees.

Rules That Protect Margin Without Hurting Conversion

You do not need to kill promotions to fix this. You need guardrails. Five rules cover most of the damage.

1. Cap the total discount stack

Set a maximum combined discount percentage (we recommend 35%). Any order whose discount line items, summed, exceed 35% of subtotal gets blocked or flagged. Shopify Functions API can enforce this at checkout for plans that support it; otherwise enforce at order webhook and cancel.

2. Disable free shipping below an order value threshold

Free shipping on a $25 order with $9 of actual carrier cost is a 36% margin hit before anything else. Set the threshold to at least 4x your average shipping cost. Shopify Shipping settings handle this natively.

3. Block coupon codes on already-discounted SKUs

In Shopify, every discount can be scoped to specific collections. Create a "On Sale" collection that auto-includes products with compare-at pricing, and exclude that collection from your codes. Stops the double-dip.

4. Enforce one discount per order

Shopify supports this natively. Settings → Discounts → uncheck "Allow combinations." Annoying for some loyalty programs but the simplest stack guardrail.

5. Auto-cancel orders below your margin floor

Even with the above, edge cases sneak through. Set a minimum profit per order (we use $5 as a floor for most stores). Orders below that get flagged and the merchant decides whether to cancel and refund or ship and learn. See our guide on how to identify unprofitable orders before they ship for the exact webhook setup.

How to Implement These in Shopify

Three layers of enforcement are available, in order of effort:

Native settings: Discounts → Combinations, plus shipping thresholds in Settings → Shipping, plus collection-based discount targeting. Zero code, covers maybe 60% of the problem.

Shopify Functions: JavaScript-based logic that runs at checkout and can reject discount combinations, enforce stack caps, or block on cart value rules. Requires Shopify Plus or developer help, but the most flexible native option.

Webhook-based flagging: Subscribe to the orders/create webhook, calculate true profit, and either tag low-margin orders (for review) or cancel and refund automatically. This is how Profit Guard works, and it catches discount damage that slips past checkout logic.

Measuring Discount Impact

The reason most stores never fix discount stacking is that they never measure it. You need to see, per discount code and per promotion, what the average margin looked like on orders that used it. The fix here is to record discount_codes and total_discount as separate fields on every order in your reporting, then group by code and average the resulting profit.

Most accounting tools cannot do this because they batch revenue and COGS at end of month. You need per-order data. Once you have it, the conversation shifts: instead of "did the promo lift revenue?" you ask "did the promo lift profit?" That single metric change is what the profit per order vs revenue trade-off is really about.

The Promo You Should Actually Run

Discounts work, but the highest-ROI promotions tend to be the smallest ones. A 10% off, capped, single-use code with a $50 minimum order value typically beats a 30% sitewide sale on a margin-weighted basis. The reason: the smaller discount preserves margin per order, and the minimum order value forces AOV up, which dilutes fixed per-order costs like payment fees. Test both and compare profit per order.

Catch margin-killing orders automatically

Profit Guard flags orders below your margin floor in real time, with the full discount and COGS breakdown. Free tier, no credit card.

Install Profit Guard on Shopify