Skip to main content

Order Routing Rules

Order routing rules are declarative manifests that match cart lines to fulfillment locations. Unlike fulfillment_constraints functions (which run WASM and can block order placement), routing rules are pure JSON matchers evaluated by the platform at order placement. Use routing rules when the assignment is data-driven (SKU prefix, tag, country, line attribute) and fulfillment_constraints when you need code (call your inventory service, look up real-time stock, hit a 3PL API).
Status — install accepted, runtime not yet wired.The install pipeline accepts and persists routing-rule manifests today (under extensions/<domainSlug>/<app-handle>/order-routing-rules/). They surface through the local manifest reader as the fulfillment_location_rule type. This type is frontend-parsed only — the backend has no dispatch or active-install cap for it yet, so no per-shop limit is enforced at install.However, the runtime evaluator that consults these rules at order placement is not yet live. The only fulfillment-routing logic that fires today is fulfillment_constraints, which runs at order placement after order_validation. Until the rule evaluator lands, install routing rules for forward compatibility and rely on fulfillment_constraints for any logic you need to enforce.

When to use rules vs constraints

The two are complementary. A typical setup:
  1. fulfillment_constraints narrows the set of locations a line can ship from (block if zero, otherwise narrow to the eligible set).
  2. Routing rules pick the preferred location from that narrowed set (West Coast → Oakland; everything else → New Jersey).
When both run, constraints execute first; the rule evaluator only sees lines that survived constraint blocking.

Where rules live

Each rule is one entry in extensions.orderRoutingRules on your app.json. After install, each entry is persisted as a single schema file at:
The local manifest reader flattens these into the canonical function shape with type: 'fulfillment_location_rule', exposing a single union of all routing rules across all installed apps. There is no per-shop cap on the number of rules — install as many as you need.

Manifest

Fields

Match operators

Paths use dotted notation against the cart input. A path can be a literal field name or include [] to project across an array.

Full operator list

Boolean composition

Multiple keys in the same match block are ANDed. For explicit boolean logic, use any (OR) or all (AND) lists at the top level:
The above matches when (country == US OR country == CA) AND totalPrice >= 50.

Common paths

Array projections ([]) match if any line satisfies the inner predicate. To require all lines to match, wrap in all:

Assignment

When several rules match, the platform picks the one with the highest priority. Ties are broken by declaration order across apps — there is no defined cross-app ordering today, so prefer unambiguous priorities when two apps might match the same line.

Fallback

A catch-all rule:
An empty match: {} matches anything. The fallback: true flag tells the evaluator to only consider this rule when nothing else matched. With fallbacks, you don’t need to enumerate every possible region — write the specifics, then catch the rest.

Worked examples

West Coast US → Oakland; everything else → Newark

Logic: a Californian order matches both rules. us-west has priority: 10 and wins. An Idaho order only matches us-default and ships from Newark.

Hazmat → licensed hub regardless of region

priority: 100 outranks the regional rules above. Any cart containing a hazmat line is routed to the hazmat hub, ignoring shipping address.

International → 3PL

Anything outside the US and Canada goes to DHL’s 3PL. This rule will be beaten by the hazmat rule above (priority 100), so an international hazmat order still goes to the hazmat hub.

Backorder → drop-shipper

A line whose inventory_state attribute is "backorder" (typically populated by your inventory app via a cart_transform function) is sent straight to the drop-shipper, bypassing all other routing.

High-value orders → expedited centre

Inspection

Once the runtime evaluator is wired, the result of routing will be persisted on the order’s additionalFields.orderRouting:
This is the audit trail the fulfilment dashboard reads to show “this line goes to Oakland because rule us-west matched at priority 10”. A line that has no matching rule is omitted from the array — the merchant’s manual fulfilment workflow handles it.

Interaction with fulfillment_constraints

When both routing rules and a fulfillment_constraints function are installed for the same store, the platform runs them in this order: The rule evaluator respects the narrowed set: a rule that assigns oakland-dc to a line whose constraint allows only [newark-dc] is ignored for that line. Use fulfillment_constraints to enforce hard physical limits (a location is the only one with stock) and use routing rules to express preferences within the feasible set.

Per-shop cap

Because fulfillment_location_rule has no backend function-limit entry yet, there is currently no active-install cap enforced for routing rules — the manifest is accepted and persisted, but nothing rejects or counts them at install. A cap will be introduced when the runtime evaluator ships.

See also