Cart & Checkout Validation
Overview
Cart & Checkout Validation lets you block buyers from completing checkout when their cart, customer profile, product mix, or delivery address matches a rule you define. All rules run through a single Shopify Function and emit errors targeted at specific fields in the checkout form so the buyer sees a precise, actionable message.
This function uses most of the condition types of your discount rules and adds three delivery-address conditions. It has no market, product, or productVariant condition. See Condition Support for the full list.
Plan requirement: All plans (max 5 rules on Starter, 10 on Pro, 30 on Enterprise)
Important: Validation rules are authored inside Shopify Admin → Settings → Checkout → Checkout rules, not inside the Alfo app. The Alfo app provides a read-only list where you can see every rule, toggle it on or off, delete it, and ask the AI to explain what it does. Clicking Edit on a rule deep-links you to Shopify’s native settings screen.
Use Cases
| Use Case | Description |
|---|---|
| Block high-value B2C orders | Reject orders over $5,000 unless the customer has a wholesale tag, directing large buyers to your sales team. |
| Require a gift message | When any cart line has the gift tag, require a gift_message cart attribute before the buyer can complete checkout. |
| Block shipping to specific countries | Prevent orders shipping to sanctioned or unsupported countries with a clear explanation. |
| Limit large quantities | Block checkout when one cart line holds more than a set number of units, so the buyer lowers the quantity before paying. |


What Happens When a Rule Matches
Every rule blocks. When the conditions of an enabled rule match, the function emits the rule’s error message, and the error prevents checkout from completing. The buyer sees the message and must change the cart, address, or account before proceeding. Without an error message, the buyer sees the rule name. There is no warn-only mode: a rule cannot show a notice and still let the buyer continue.
Buyer Journey Step Targeting
Each rule can restrict when it runs by specifying a buyer journey step. Only rules matching the current step are evaluated, which keeps errors from appearing at irrelevant points in the flow. In the editor, the step is the Trigger at field. A new rule starts at Order submission.
| Trigger at (editor) | Step | When the Rule Runs |
|---|---|---|
| Cart page | cartInteraction | While the buyer browses the cart, before entering checkout. |
| Checkout fields | checkoutInteraction | As the buyer fills in the checkout fields. |
| Order submission | checkoutCompletion | When the buyer clicks “Complete order”. The rule prevents the order if its conditions match. |
| (not offered) | (omitted) | The rule runs at every step. The editor does not offer this choice, and a new rule starts at Order submission. |
checkoutCompletion is usually the right choice: it prevents the order from going through without showing errors mid-form. cartInteraction or checkoutInteraction shows the error earlier, so the buyer can fix the cart or the address before paying. To stop the order, use checkoutCompletion (Order submission).
Error Targeting
Each rule specifies where its error message attaches in the checkout form. This controls which input the error renders next to, so buyers see the message against the field they need to change.
| Target | Where the Error Appears |
|---|---|
$.cart | Generic cart-level banner (default). Use when the error isn’t tied to one specific field. |
$.cart.buyerIdentity.email | Next to the email input on the contact step. |
$.cart.deliveryGroups[0].deliveryAddress.countryCode | Next to the country selector on the shipping-address step. |
$.cart.billingAddress.phone | Next to the phone input on the billing-address step. |
When you pair the target with the right buyer journey step, the error feels native to the checkout flow rather than like an unexpected interruption.
Condition Support
Validation rules can combine three condition categories with AND/OR logic, identical to how discount rule groups work.
Cart-Level Conditions
customerTag, customerIsAuthenticated, customerOrderCount, customerTotalSpent, cartSubtotal, cartTotalQuantity, cartLineCount, cartAttribute
Product-Level Conditions
productTag, collection, lineQuantity, linePrice, lineProperty
For productTag, has none of matches when no product in the cart has one of the tags. For collection, in none of matches when no product in the cart is in one of the collections. To catch a cart where some product does not have a tag, tag the products that the rule must catch and use has any of.
Delivery-Level Conditions
deliveryCountry, deliveryProvince, deliveryZip
The three delivery-level conditions evaluate against the shipping address on the cart. They let you write rules that only trigger for buyers shipping to (or away from) specific regions.
Strategy Modes
When a validation has multiple rules, the strategy controls how they are combined:
first: stop at the first matching rule. The buyer sees one error at a time.all: evaluate every rule and emit an error for each one that matches. The buyer sees every applicable error at once.
Use first for priority-based validations (for example, country-block before cart-size-block). Use all when the errors are independent and the buyer benefits from seeing everything that needs fixing.
Example Configurations
For step-by-step rules that set a minimum order value or limit quantities, see Minimum Order Value and Maximum Quantity at Checkout.
Block Large B2C Orders
Prevent retail customers from placing orders over $5,000 and redirect them to your wholesale team.
| Setting | Value |
|---|---|
| Conditions (AND) | Cart subtotal greater than $5,000; customer tag has none of wholesale |
| Buyer Journey Step | checkoutCompletion |
| Error Target | $.cart |
| Message | ”Large orders require a wholesale account. Please contact sales@example.com.” |
Require a Gift Message
When a gift-tagged product is in the cart, require the buyer to supply a gift message attribute before checkout can complete.
| Setting | Value |
|---|---|
| Conditions (AND) | Product tag has any of gift; cart attribute gift_message does not exist |
| Buyer Journey Step | checkoutCompletion |
| Error Target | $.cart |
| Message | ”A gift message is required for items marked as gifts. Please add one in your cart before checking out.” |
Limit the Quantity of One Item
Block checkout when any cart line holds more than 10 units.
| Setting | Value |
|---|---|
| Conditions (AND) | Line quantity greater than 10 |
| Buyer Journey Step | checkoutCompletion |
| Error Target | $.cart |
| Message | ”You can order up to 10 units of each item. Please lower the quantity.” |
Managing Validations in the Alfo App
The Cart & Checkout Validations page in the Alfo admin gives you a read-only overview of every validation configured for your store:
| Feature | Description |
|---|---|
| List view | See every validation with its status (enabled/disabled), rule count, and strategy mode. |
| Summary view | For each rule, inspect its conditions, buyer journey step, error target, and error message side-by-side. |
| Toggle | Turn a validation on or off without deleting it. |
| Delete | Remove a validation you no longer need. |
| AI Explain | Ask the AI to describe what a validation does in plain language. Free on all plans. |
Creating or editing rule content happens in Shopify’s native Checkout settings, not in the Alfo app. Clicking Edit on any rule opens the corresponding Shopify Admin screen in a new tab.
Next Steps
- Minimum Order Value and Maximum Quantity at Checkout: step-by-step rules for a minimum order value, a quantity limit for each item and a limit on the items per order.
- Guides by Goal: every Alfo guide, listed by store goal.
- Payment Customization: control payment methods at checkout.
- Delivery Customization: control delivery options at checkout.
- Checkout Upsells: offer pre-purchase products inside checkout (Pro and Enterprise, Shopify Plus stores only).
- Cart-Level Conditions: reference for the cart and customer conditions.