How to block a Shopify checkout when a specific discount code is applied
Discount codes have a way of escaping the audience you gave them to. A trade code meant for your wholesale buyers shows up on a coupon site. An affiliate’s code gets passed around a group chat until orders arrive with margins you never agreed to. A partner keeps ordering below the minimum written into the agreement, because nothing at checkout ever told them to stop. You can cancel these orders after payment, pay the processing fee, and write the apology email. Or you can stop them at checkout, before payment, with a message that says exactly what’s wrong.
In this article, I’ll show the checkout rules that handle these situations on Shopify. I built Validify Checkout Guard, the app used here, so this comes from the person who made it. Every rule is built as criterion + operator + value, the same pattern behind fraud prevention and B2B checkout rules, so each situation below comes with the exact rule to copy.
The trade code that leaked
You give trade buyers a code, TRADE50, for their wholesale pricing. Months later it’s on a coupon site, and consumers are ordering at prices you only offered to businesses. The orders are valid-looking, paid, and wrong, and every one you cancel costs a processing fee.
The rule separates the audience from the code:
- Criterion: B2B checkout / operator: is false
- Criterion: applied discount / operator: is / value: TRADE50, picked from the discount picker
The order stops when a consumer, not a company account, uses the trade code. The buyer sees a message that tells them the way in: “This code is for wholesale accounts. Please log in with your company account to use it.” Your wholesale buyers never notice the rule exists, because their checkouts meet the first condition.
The partner who orders under the minimum
Partner agreements often carry a minimum, usually a weight or an amount, because a partner order below it isn’t worth the freight. Buyers ignore minimums that only exist in the agreement PDF. Put it where they can’t miss it:
- Criterion: B2B checkout / operator: is true
- Criterion: applied discount / operator: is / value: TRADE50
- Criterion: total cart weight / operator: is less than / value: 20000
The order stops when the partner code is applied on a B2B checkout and the cart weighs under 20 kg, with a message like “Partner orders have a minimum total weight of 20 kg. Please add items to continue.” The buyer is one click of “add more” away from a valid order instead of a cancellation email. How the weight side of this rule works, including grams conversion, is covered in the cart weight article.
The resale buyout behind a shared code
When a code circulates publicly, resellers find it fast. The signal is the combination: a heavily discounted order with an unusual quantity. Stop it with:
- Criterion: applied discount / operator: is one of / value: your public codes, picked from the discount picker
- Criterion: total quantity / operator: is greater than / value: 6
Everyday buyers buying one or two items never trip it. The six-unit order at 30 percent off does, with the usual message: “To keep stock available for everyone, we limit purchases to 6 items per customer. Please adjust your quantity.”
How the rule reads your discount
In the rule builder, a discount condition gets its value from a picker: you search your store’s discounts and pick them by title, the same way you pick a product or a company for other criteria. The operators are is, is not, is one of, and is not one of, so one condition can cover a family of codes.
Two things about the matching are worth knowing, because both save support questions later. The rule points at the discount itself, not its code string, so editing or renaming the code doesn’t break the rule. And the app maintains the link to your discounts on its own after every save; you’ll see small markers on the tagged discounts in your Shopify admin if you look, but there’s nothing to manage. The first release of this feature asks you to approve new discount-related permissions once, when the app updates.
What the rules can’t do
One limit is deliberate: a cart with no discount at all never matches, including under “is not”. The condition reads what was applied, and a cart where nothing was applied has nothing to read. So you cannot build “block B2B orders where TRADE50 wasn’t used”; put the minimum on its own weight or amount condition instead, and use the discount criterion to narrow it.
The others are smaller. A picked discount that gets deleted keeps showing its ID in the rule, and if you recreate the discount you re-pick it once and save. And the rules see which discount was applied, not its arithmetic: for “the discount amount is above X” you’d use a cart total condition instead.
Getting started
The checkout guard is $5 a month with a 7-day free trial. Start with the one situation you actually have, copy its rule, and write the message that tells the buyer the way forward. Then spend the trial watching real orders, both for anything over-blocked and for codes you forgot you’d picked. If setup gives you trouble, I answer support myself within 24 hours. You can check the app details here.