Coming soon: Blockly Checkout Customizer — validation rules, upsells & checkout analytics.Get early access
Tutorial

Stop Certain Products From Being Purchased Together on Shopify

Some products should never share a cart. Learn how to block risky combinations like gift cards with discounted bundles, hazmat with air shipping, or pre-orders with in-stock items using Shopify Functions.

Stop Certain Products From Being Purchased Together on Shopify

Most cart rules are about how much a customer buys. This one is about what they buy together. A gift card next to a heavily discounted bundle, an aerosol next to an express air shipment, a pre-order sitting beside an in-stock item that the customer expects tomorrow. Each product is fine on its own. The combination is what creates the problem.

Shopify does not give you a native setting for "these two things cannot be in the same order." But with a Cart and Checkout Validation function, you can stop the combination at checkout and tell the customer exactly what to change.

Why product combinations cause trouble

Incompatible carts rarely look dangerous when they come in. The cost shows up later, in fulfillment, support, or margin.

Discount stacking and laundering. Buying gift cards inside a cart that also qualifies for a big bundle discount can let customers convert promotional value into stored value. It is also a common pattern in gift card fraud, where stolen payment details are used to buy cards alongside ordinary products to look normal.

Shipping restrictions. Hazardous materials such as aerosols, lithium batteries, or certain fragrances often cannot travel by air. If they share a cart with a product that triggers an express or international air rate, the order either ships illegally, ships late, or gets split at your expense.

Fulfillment timing. A pre-order with a release date weeks away, combined with an in-stock item, forces a choice: hold the whole order, or split it and pay for two shipments. Customers who expected the in-stock item quickly will contact support either way.

Your options on Shopify

Native Shopify settings

There is no built-in "mutually exclusive products" setting. You can approximate some cases indirectly: separate shipping profiles can keep hazmat items off air rates, and gift cards can be excluded from many discounts. But none of these stop the cart from being created, and none tell the customer why something is wrong.

Theme and cart page hacks

A common workaround is JavaScript on the cart page that removes one item when another is added, or hides the checkout button. This is fragile. Customers can reach checkout through express buttons, direct checkout links, the Shop app, or a cached page, and every one of those paths skips your cart script. Theme logic is a UX hint, not an enforcement layer.

Shopify Functions (validation)

A Cart and Checkout Validation function runs server-side every time the cart or checkout is evaluated. It can read line items, product tags, collections, variant metafields, and quantities, then return an error that blocks checkout until the cart is fixed. Because it runs on Shopify's servers, it applies regardless of how the customer arrived at checkout.

Public apps that use validation functions work on all Shopify plans. If you build your own custom app with a validation function, that generally requires Shopify Plus. For a broader look at the validation layer, see our guide to Shopify checkout validation rules.

Step-by-step setup

1. Classify your products

Rules work best when they target groups, not individual products. Before writing any rule, tag or organize the products involved:

  • hazmat for aerosols, batteries, and flammable items
  • pre-order for items not yet in stock
  • gift-card or the native gift card product type
  • bundle-promo for discounted bundles
  • subscription for subscription-only items

Tags are easy to maintain and easy for a validation rule to read. Collections or metafields work too, but pick one approach and stay consistent.

2. Write down each conflict as a pair

For every rule, define group A, group B, and what should happen. For example: "If the cart contains any pre-order item AND any item that is not pre-order, block checkout." Writing the pair down first prevents vague rules that block more than intended.

3. Write the customer message

The error is the only thing the customer sees, so it needs to explain the fix. "Your cart contains invalid items" creates support tickets. "Pre-order items must be checked out separately from in-stock items. Please remove one group to continue." solves the problem in one read.

4. Test every path to checkout

Test from the cart page, the product page express buttons, a direct checkout link, and a logged-in customer account. The rule should fire the same way on each.

5. Monitor and adjust

Watch support messages for the first couple of weeks. If customers are confused, fix the message before the rule.

Rule examples

ConflictConditionCustomer message
Gift card with promo bundleCart has a gift card AND any item tagged bundle-promoGift cards can't be purchased with promotional bundles. Please check out your gift card separately.
Hazmat with air shippingCart has an item tagged hazmat AND an item tagged air-onlySome items in your cart can't ship by air. Please order them separately.
Pre-order with in-stockCart has an item tagged pre-order AND an item without that tagPre-order items ship on their release date. Please check them out separately from in-stock items.
Subscription with one-time itemCart has an item tagged subscription AND an item tagged one-time-onlySubscriptions must be checked out on their own.
Sample with full-sizeCart has an item tagged sample AND the matching full-size productSamples are only available on orders without the full-size product.
Keep each rule to one conflict. Two simple rules are easier to debug than one rule with five conditions.

Hazmat and shipping: validate or hide?

For hazmat, you have two tools. Validation blocks the order entirely until the customer changes the cart. Delivery customization can instead hide air or express rates when a hazmat item is present, letting the order proceed on ground shipping. If ground shipping is an acceptable outcome, hiding the rate is the gentler option. Our guide on hiding shipping methods with Shopify Functions covers that approach. Use validation only when there is no acceptable shipping option for the combination.

Pitfalls and edge cases

Rules that trap the customer. If removing either product still leaves a conflict, the customer cannot check out at all. Check that every rule has a clear way out.

Untagged new products. A new pre-order product that someone forgets to tag will slip through. Add tagging to your product launch checklist.

Bundles built by apps. Some bundle apps represent a bundle as a parent product with component lines, or as separate line items. Test how your bundle app appears in the cart before relying on bundle tags.

Draft orders and B2B. If you sell wholesale, confirm whether the rule should apply to B2B buyers too. Wholesale buyers often need to mix pre-orders with in-stock replenishment, and a blanket rule can get in their way.

Messages that sound like errors. Customers read "blocked" as "broken." Phrase messages as guidance, and name the specific items when possible.

Setting this up with Blockly Checkout Customizer

Blockly Checkout Customizer, launching soon on the Shopify App Store, is built to handle product-combination rules without code. You will be able to select two product groups by tag, collection, or specific product, choose "cannot be purchased together," and write the checkout message customers see. Because it runs on Shopify Functions, the rule applies on every path to checkout, and as a public app it is designed to work on all Shopify plans, not just Plus.

The same app also covers related rules from this series, such as limiting order quantity per product and minimum order values, so combination rules can live alongside your other checkout logic.

Takeaway

Incompatible product combinations are a quiet cost: split shipments, compliance risk, discount abuse, and support tickets. Theme scripts cannot enforce them reliably because customers reach checkout through too many doors. A validation function closes every door at once. Start by tagging the products involved, write each conflict as a simple pair, give customers a message that tells them how to fix the cart, and test every path to checkout before you call it done.

Up nextBlock or Allow Checkout by Customer Tag on Shopify

Related articles

More tutorial articles →
Free forever plan

Ready to protect
your store?

Join 5,000+ Shopify merchants. Install in 30 seconds and block your first bad actor today.

  • No credit card
  • 5-minute setup
  • Cancel anytime