Customer Rules
Navigate to yStore → Marketing → Customer Rules.
Customer rules define automatic segmentation logic — moving customers into groups or tagging them based on behavior, order history, and other conditions. Rules run on a schedule so your customer segments stay accurate without manual effort. Segmentation feeds directly into coupons, catalog price rules, flows, and personalized storefront content.
What customer rules do
A customer rule monitors your customer base for accounts that match a defined set of conditions, then performs an action — typically moving the customer into a group or applying a tag.
Rules re-evaluate on each CRON cycle. If a customer no longer meets the conditions (e.g., they fall below a spend threshold), you can configure the rule to reverse the action — or leave them in the group and let other rules handle downgrades.
How segmentation connects to the rest of yStore
Customer rules handle the segmentation. Everything else reacts to that segmentation:
| Tool | How it uses customer groups / tags |
|---|---|
| Coupons | Restrict coupon eligibility to a specific customer group |
| Catalog price rules | Show discounted prices only to customers in a specific group |
| Flow Manager | Use "Customer is in group" conditions in flows; "Customer Group Changed" can trigger flows |
| Shipping rules | Offer exclusive or discounted shipping to specific groups |
| Storefront | Show/hide content blocks based on currentUser.isInGroup('vip') |
Common use cases
- Loyalty & VIP
- Re-engagement
- B2B / Wholesale
- Onboarding
| Goal | Conditions | Action |
|---|---|---|
| VIP tier after high lifetime spend | Lifetime order total > €500 | Move to VIP group |
| Loyal customer milestone | Order count ≥ 5 | Move to loyal-customers group |
| High-frequency buyer | Orders in last 30 days ≥ 3 | Add tag frequent-buyer |
| Large average order | Average order value > €150 | Move to premium group |
| Goal | Conditions | Action |
|---|---|---|
| At-risk segment | No order in 90 days | Move to at-risk group |
| Lapsed customer | No order in 180 days | Move to lapsed group |
| Win-back candidate | In at-risk + was previously VIP | Add tag win-back-vip |
| Goal | Conditions | Action |
|---|---|---|
| Wholesale access | Company field is filled | Move to Wholesale group |
| Tax-exempt B2B | VAT number field is filled | Move to vat-exempt group |
| Large account | Lifetime spend > €5,000 | Move to key-account group |
| Goal | Conditions | Action |
|---|---|---|
| First-purchase tag | Order count = 1 | Add tag first-buyer |
| New account (no purchase yet) | Account age < 7 days AND order count = 0 | Add tag new-no-purchase |
| Second purchase milestone | Order count = 2 | Remove tag first-buyer, add tag repeat-buyer |
Customer rules + flows: a practical example
Customer rules handle segmentation. Flows handle what happens as a result of that segmentation.
Example — VIP upgrade sequence:
- Customer Rule: detects customer's lifetime order total crosses €500 → moves them to
VIPgroup. - Flow:
Customer Group Changedcondition fires → detects group =VIP→ sends VIP welcome email with exclusive coupon → addsvip-enrolledtag to the order.
This separation keeps each tool focused:
- Customer rules: who qualifies
- Flows: what happens when they qualify
See Flow Manager for flow setup.
Creating a customer rule
- Go to
yStore → Marketing → Customer Rules. - Click New Customer Rule.
- Enter a name for the rule (internal, not shown to customers).
- Add conditions — these filter which customers qualify.
- Select the action: move to group, add tag, remove tag, etc.
- Set the evaluation schedule (or leave as default CRON interval).
- Enable the rule and Save.
When setting up a new rule, run it manually first to preview which customers it will match before enabling automatic evaluation. This prevents unexpected mass group changes.
php craft yui/customer-rules/evaluate --id=5 --dry-run
Console commands
# Evaluate all active customer rules now
php craft yui/customer-rules/evaluate
# Evaluate a specific rule by ID
php craft yui/customer-rules/evaluate --id=5
# Dry run — show which customers would be affected without making changes
php craft yui/customer-rules/evaluate --dry-run
# Reset all customer group assignments made by rules and re-evaluate from scratch
php craft yui/customer-rules/reset
Conditions available
Customer rule conditions can evaluate:
| Category | Examples |
|---|---|
| Order history | Total order count, lifetime spend, average order value |
| Recency | Days since last order, days since registration |
| Customer data | Company field, country, custom profile fields |
| Account status | Is guest, is approved, has verified email |
| Current group | Already in group X (useful for chained rules) |
| Tags | Has / does not have a specific tag |
Multiple conditions can be combined with AND/OR logic.
Avoiding segmentation conflicts
When multiple rules can affect the same customer, be deliberate about the order:
- Priority field controls which rule runs first when conditions overlap.
- Use "Discard subsequent rules" (if available) to prevent a high-priority rule's customers from being re-evaluated by lower-priority rules.
- Design your rules so the groups are mutually exclusive where needed — for example, a customer should not be in both
standardandVIPat the same time unless that is intentional.
If Rule A moves a customer to Group X, and Rule B (lower priority) then moves them to Group Y, the customer ends up in Group Y — unless Rule A has "discard subsequent" enabled. Test your rule stack carefully.