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 CaseDescription
Block high-value B2C ordersReject orders over $5,000 unless the customer has a wholesale tag, directing large buyers to your sales team.
Require a gift messageWhen any cart line has the gift tag, require a gift_message cart attribute before the buyer can complete checkout.
Block shipping to specific countriesPrevent orders shipping to sanctioned or unsupported countries with a clear explanation.
Limit large quantitiesBlock checkout when one cart line holds more than a set number of units, so the buyer lowers the quantity before paying.
Validation rule Max 2 of each item with the condition Line Quantity, greater than, 2
A rule that limits each item to 2: Line Quantity, greater than, 2.
Checkout message: You can buy up to 2 of each item per order. Lower the quantity to continue.
The message of that rule as buyers see it in checkout. This test ran the rule at the Checkout fields step.

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)StepWhen the Rule Runs
Cart pagecartInteractionWhile the buyer browses the cart, before entering checkout.
Checkout fieldscheckoutInteractionAs the buyer fills in the checkout fields.
Order submissioncheckoutCompletionWhen 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.

TargetWhere the Error Appears
$.cartGeneric cart-level banner (default). Use when the error isn’t tied to one specific field.
$.cart.buyerIdentity.emailNext to the email input on the contact step.
$.cart.deliveryGroups[0].deliveryAddress.countryCodeNext to the country selector on the shipping-address step.
$.cart.billingAddress.phoneNext 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.

SettingValue
Conditions (AND)Cart subtotal greater than $5,000; customer tag has none of wholesale
Buyer Journey StepcheckoutCompletion
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.

SettingValue
Conditions (AND)Product tag has any of gift; cart attribute gift_message does not exist
Buyer Journey StepcheckoutCompletion
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.

SettingValue
Conditions (AND)Line quantity greater than 10
Buyer Journey StepcheckoutCompletion
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:

FeatureDescription
List viewSee every validation with its status (enabled/disabled), rule count, and strategy mode.
Summary viewFor each rule, inspect its conditions, buyer journey step, error target, and error message side-by-side.
ToggleTurn a validation on or off without deleting it.
DeleteRemove a validation you no longer need.
AI ExplainAsk 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