Validation Function
The validation function ensures MUP compliance at checkout by blocking orders that violate minimum unit pricing requirements.
Setup Required
Important: The validation function must be added to your checkout rules manually:
- Go to Shopify Admin → Settings → Checkout
- Scroll to Checkout rules section
- Click "Add a checkout rule"
- Select "Cart validation" as the rule type
- Find and select "MUP Validation" function
- Click "Save"
The function is automatically deployed with the app, but must be added to checkout rules to be active.
What It Does
Before a customer can complete checkout, the validation function: 1. Checks if customer is in Scotland 2. Validates product prices after discounts 3. Blocks checkout if price per unit < MUP floor 4. Shows error message to customer
When It Runs
The validation function runs: - When customer attempts to checkout - Before payment processing - After discounts are applied
What It Checks
Price Validation
For each product in cart: 1. Gets final price (after discounts) 2. Calculates price per unit 3. Compares to MUP floor 4. Blocks if below minimum
Address Detection
The function also checks: - Billing address postcode - Shipping address postcode - Detects Scottish postcodes automatically
If a Scottish postcode is detected but region is not set to Scotland, shows warning.
Error Messages
Price Violation
Message: "Minimum Unit Pricing (MUP) applies to this order. The discounted price of [Product] is below the legal minimum of £0.65 per alcohol unit. Please remove your discount code or return to cart to review pricing."
Action required: - Customer must remove discount code - Or return to cart to review
Address Mismatch
Message: "Scottish address detected ([Postcode]). Please return to your cart and select 'Scotland' as your region to ensure correct pricing and MUP compliance before completing your order."
Action required: - Customer must return to cart - Select Scotland as region - Return to checkout
Order Tagging
Orders with address mismatches are tagged:
- MUP_NON_COMPLIANCE - Address mismatch detected
These tags help identify orders needing manual review.
Troubleshooting
Validation not blocking checkout? - Verify validation function is added to checkout rules - Check that function is enabled in checkout rules - Ensure MUP enforcement is enabled - Review function logs for errors
Validation blocking incorrectly?
- Check product total_units metafield
- Verify minimum unit price setting
- Review discount code configuration
Not blocking when it should? - Ensure MUP enforcement is enabled - Check customer region is Scotland - Verify validation function is active in checkout rules
For more help, see Troubleshooting.