Cart & Checkout Validation
Overview
Cart & Checkout Validation lets you block buyers from completing checkout — or surface a warning without blocking them — when their cart, customer profile, product mix, or delivery address fails 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 the same condition engine as your discount rules, so you can reuse the patterns you already know.
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
- Block high-value B2C orders — Reject orders over $5,000 unless the customer has a
wholesaletag, directing large buyers to your sales team. - Require a gift message — When any cart line has the
gifttag, require agift_messagecart attribute before the buyer can complete checkout. - Block shipping to specific countries — Prevent orders shipping to sanctioned or unsupported countries with a clear explanation.
- Warn on stock-keeping thresholds — Surface a non-blocking warning when the cart quantity of a single SKU passes a threshold (for example, 50 units of a small-run product) so the buyer can adjust before paying.
Actions
A validation rule can apply one of two actions when its conditions match:
| Action | Buyer Experience |
|---|---|
| Block | Emits an error that prevents checkout from completing. The buyer sees the message and must change the cart, address, or account before proceeding. |
| Warn | Surfaces the same error text without preventing checkout. Useful for advisories where the buyer should see a notice but still has the option to 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.
| Step | When the Rule Runs |
|---|---|
cartInteraction | The buyer is interacting with the cart page (adding, removing, or changing quantities). |
checkoutInteraction | The buyer is filling out the checkout form. |
checkoutCompletion | The buyer has submitted the order for final processing. |
| (omitted) | The rule runs at every step. |
For “block” actions, checkoutCompletion is usually the right choice — it prevents the order from going through without surfacing warnings mid-form. For “warn” actions, cartInteraction or checkoutInteraction is often more helpful since it gives the buyer a chance to see the notice early.
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
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
Block Large B2C Orders
Prevent retail customers from placing orders over $5,000 and redirect them to your wholesale team.
- Conditions (AND):
- Cart subtotal greater than $5,000
- Customer tag has none of
wholesale
- Action: Block
- Buyer Journey Step:
checkoutCompletion - Error Target:
$.cart - Message: “Orders over $5,000 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.
- Conditions (AND):
- Product tag has any of
gift - Cart attribute
gift_messagedoes not exist
- Product tag has any of
- Action: Block
- 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.”
Warn on Large Quantities of a Limited SKU
Surface a non-blocking warning when a buyer adds more than 10 units of a product tagged limited-run.
- Conditions (AND):
- Product tag has any of
limited-run - Line quantity greater than 10
- Product tag has any of
- Action: Warn
- Buyer Journey Step:
cartInteraction - Error Target:
$.cart - Message: “This is a limited-run product. Orders over 10 units may ship in multiple deliveries.”
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:
- List view — See every validation with its status (enabled/disabled), rule count, and strategy mode.
- Summary view — For each rule, inspect its conditions, action, 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
- Payment Customization — Control payment methods at checkout.
- Delivery Customization — Control delivery options at checkout.
- Checkout Upsells — Offer pre-purchase products inside checkout.
- Cart-Level Conditions — Reference for every condition available in validation rules.