Merchant rules is a versioned rule engine for cart discounts and checkout blocks. Rules are declarative JSON; there is no merchant-authored JavaScript.
Create a rule set
Open Merchant rules
In the admin sidebar, choose Merchant rules.
Edit the Rules JSON
The editor expects a document with a
rulesarray. Each rule has anid, optionalname,enabled,whenconditions, and onethenaction.Save a draft
Select Save draft. The server rejects unknown fields, duplicate ids, invalid percentages, and documents larger than 32 KiB.
Activate a version
In Version history, select Activate on a saved version. The previously active version is archived and new carts use the new version immediately.
Example
{
"rules": [
{
"id": "welcome-10",
"name": "Welcome 10%",
"enabled": true,
"when": { "currency_code": "usd", "subtotal_min": 5000 },
"then": {
"type": "order_discount_percent",
"percent": 10,
"code": "WELCOME10"
}
}
]
}Conditions and actions
Conditions: currency_code, subtotal_min, subtotal_max,
item_count_min, item_count_max, product_ids, variant_ids.
Actions:
order_discount_percentorder_discount_amountline_discount_percentblock_checkout
Rules run in document order. Each discount sees the remaining base after previous adjustments. Merchant discounts apply before plugin adjustments; the host validates cumulative discounts and recomputes totals.
Simulate
Enter a Cart id in the Simulator and select Simulate. Nothing is persisted; the result shows matched rules, dropped rules, blocks, adjustments, and adjusted totals using the same validator as live cart reads.
Limits
- At most 50 rules and 100 adjustments.
- The serialized document is limited to 32 KiB.
- A malformed stored rule set fails checkout closed.