Fail Validation Action

The Fail Validation action allows you to prevent customers from placing an order with an error message targeted at a specific field. This ensures data integrity, enforces business rules, and prevents invalid orders from being placed.

Purpose

This action prevents checkout completion when specific conditions aren’t met, displaying custom error messages to guide customers in resolving issues. It’s essential for:

  • Enforcing business rules
  • Preventing invalid orders
  • Protecting inventory
  • Ensuring compliance
  • Improving data quality

Error Message Configuration

Message Properties

  • Error Text: The message displayed to the customer
  • Field Target: Which checkout field to highlight
  • Language: Localized message support

Field Targets

Error messages can be attached to:

  • Cart Level: General cart validation
  • Line Items: Specific product issues
  • Quantity Fields: Quantity-related errors
  • Delivery Address: Shipping restrictions
  • Delivery Method: Shipping option issues
  • Payment Method: Payment restrictions
  • Discount Code: Coupon/discount issues
  • Customer Info: Account-related validations

Validation Rules

Product Validations

  • Minimum/maximum quantity per product
  • Product availability by location
  • Product combination restrictions
  • Age-restricted products
  • Prescription requirements
  • License verification

Cart Validations

  • Minimum/maximum order value
  • Total item count limits
  • Mixed cart restrictions
  • Category combination rules
  • Weight/dimension limits

Customer Validations

  • Account status verification
  • Customer segment restrictions
  • Purchase history requirements
  • Membership validation
  • Credit limit checks using metafields

Location Validations

  • Shipping restriction by region
  • Product availability by location
  • Service area boundaries
  • International restrictions
  • Hazmat shipping rules

Message Formatting

Dynamic Variables

Include dynamic information in messages:

  • {product_name} - Product causing the issue
  • {quantity} - Current quantity
  • {max_quantity} - Maximum allowed
  • {min_amount} - Minimum required
  • {difference} - Amount needed

Localization

Multi-Language Support

Provide translations for international customers:

EN: "Minimum order value is $50"
FR: "La valeur minimale de commande est de 50 $"
ES: "El valor mínimo del pedido es de $50"

Regional Variations

Adjust messages for different regions:

US: "Zip code required"
UK: "Postcode required"
CA: "Postal code required"

Limitations

  • Cannot modify cart contents (only validate)
  • Message length is limited
  • Validations run at specific checkout points
  • Cannot validate external systems in real-time

Regular Expressions

String conditions in validation functions support regular expression matching. Use the RegExp (case-sensitive) or RegExp* (case-insensitive) operators to match patterns in text fields like addresses, SKUs, or customer notes.

See the Regular Expressions reference for supported syntax and examples.