Skip to content

Merchant rules

Create versioned, deterministic cart rules and test them against a cart.

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

  1. Open Merchant rules

    In the admin sidebar, choose Merchant rules.

  2. Edit the Rules JSON

    The editor expects a document with a rules array. Each rule has an id, optional name, enabled, when conditions, and one then action.

  3. Save a draft

    Select Save draft. The server rejects unknown fields, duplicate ids, invalid percentages, and documents larger than 32 KiB.

  4. 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_percent
  • order_discount_amount
  • line_discount_percent
  • block_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.

Type to search…

↑↓ navigate↵ selectEsc close