Skip to main content
Version: 2.0.0

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:

ToolHow it uses customer groups / tags
CouponsRestrict coupon eligibility to a specific customer group
Catalog price rulesShow discounted prices only to customers in a specific group
Flow ManagerUse "Customer is in group" conditions in flows; "Customer Group Changed" can trigger flows
Shipping rulesOffer exclusive or discounted shipping to specific groups
StorefrontShow/hide content blocks based on currentUser.isInGroup('vip')

Common use cases

GoalConditionsAction
VIP tier after high lifetime spendLifetime order total > €500Move to VIP group
Loyal customer milestoneOrder count ≥ 5Move to loyal-customers group
High-frequency buyerOrders in last 30 days ≥ 3Add tag frequent-buyer
Large average orderAverage order value > €150Move to premium group

Customer rules + flows: a practical example

Customer rules handle segmentation. Flows handle what happens as a result of that segmentation.

Example — VIP upgrade sequence:

  1. Customer Rule: detects customer's lifetime order total crosses €500 → moves them to VIP group.
  2. Flow: Customer Group Changed condition fires → detects group = VIP → sends VIP welcome email with exclusive coupon → adds vip-enrolled tag 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

  1. Go to yStore → Marketing → Customer Rules.
  2. Click New Customer Rule.
  3. Enter a name for the rule (internal, not shown to customers).
  4. Add conditions — these filter which customers qualify.
  5. Select the action: move to group, add tag, remove tag, etc.
  6. Set the evaluation schedule (or leave as default CRON interval).
  7. Enable the rule and Save.
Start with manual evaluation

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:

CategoryExamples
Order historyTotal order count, lifetime spend, average order value
RecencyDays since last order, days since registration
Customer dataCompany field, country, custom profile fields
Account statusIs guest, is approved, has verified email
Current groupAlready in group X (useful for chained rules)
TagsHas / 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 standard and VIP at the same time unless that is intentional.
Rule order matters for group assignments

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.