Rules + sequences - Ultimate Cart Recovery (EN)
A rule binds a set of conditions (cart total, currency, customer group, store) to a sequence of 1 to 5 steps. The engine picks the highest-priority active rule that matches each tracking, and walks the steps with the configured delay between them.
Conditions JSON
visicrea_ucr_rule.conditions_serialized accepts a JSON tree:
{
"aggregator": "all",
"conditions": [
{"field": "cart_total", "operator": "gteq", "value": 50},
{"field": "currency_code", "operator": "eq", "value": "EUR"},
{
"aggregator": "any",
"conditions": [
{"field": "language_code", "operator": "eq", "value": "fr_FR"},
{"field": "is_guest", "operator": "eq", "value": false}
]
}
]
}
| Field whitelist | Operators |
|---|---|
cart_total, initial_cart_total, cart_items_count, currency_code, language_code, is_guest, customer_id, store_id, status, current_step |
eq, neq, gteq, lteq, gt, lt, in, nin, contains |
Anything outside the whitelist evaluates to false (fail closed).
Steps
Each step picks one channel:
| Channel | Body source |
|---|---|
email |
Magento email template (template_id, can be overridden per store via Marketing → Communications) |
sms |
Plain text rendered with the same template engine as email |
whatsapp |
Plain text - must match a pre-approved Twilio/Meta template (ADDENDUM A10) |
webhook |
JSON to every active visicrea_ucr_webhook_endpoint, signed |
delay_minutes is counted from the previous step's send time (for
steps 2..5), or from tracking.first_seen_at (for step 1).
Coupons
When use_coupon = 1:
- The step must point at a
coupon_sales_rule_id(Magento Cart Price Rule already configured). The module mints one coupon code attached to it per(tracking_id, step_id)pair. - Format:
VCR{tracking_id}-{6_hex}. coupon_validity_hours(optional) sets the expiry. Expired coupons are cleaned up daily byCron\CleanupExpiredCoupons(VCR-prefixed only - it never touches other merchant codes that happen to share the rule).coupon_type(percent/fixed) is informational in V1 (the Sales Rule itself drives the math).bogo/free_shippingland in V2 without a migration - the column already exists.
The template variable {{coupon.code}} is populated at render time.
Example: a 3-step default sequence
| Step | Delay (min) | Channel | Template | Coupon? |
|---|---|---|---|---|
| 1 | 60 | visicrea_ucr_email_step_1 |
no | |
| 2 | 720 (12 h) | visicrea_ucr_email_step_2 |
no | |
| 3 | 2880 (48 h) | visicrea_ucr_email_step_3 |
yes - 10 % parent rule, 72 h validity |
Multistore + customer groups
store_ids and customer_group_ids are CSV (0 = all). Combined with the
conditions tree, this lets B2B and B2C merchants run separate sequences on
the same install.