Generate an order discount Function extension via the Shopify CLI and select the order discount Function type.
In `run.graphql`, query cart subtotal and any buyer or cart attributes your logic depends on (e.g., customer tags via `buyerIdentity`, cart totals).
In the Function `run` body, evaluate the discount condition (e.g., subtotal above a threshold) and return a `FunctionRunResult` with a single order-level discount target using `orderSubtotals` or the equivalent target type — verify the exact target name against the current Function API surface in Shopify docs.
Register the Function as an automatic order discount via the Admin GraphQL API discount mutation for app-owned automatic discounts, providing the function ID, title, and combine-with settings.
Use the Partner Dashboard Function tracing tool to inspect inputs and outputs for real cart sessions on a dev store.
Deploy to production with `shopify app deploy` and confirm the registration points to the production Function ID.
Known gotchas
Order discount Functions share the same Wasm execution budget as other Function types — avoid branching logic that scales with line-item count if the catalog is large.
Combining order-level and line-item-level discounts depends on the `combinesWith` configuration at discount registration time; test all combinations explicitly because Shopify's discount stacking rules are applied platform-side, not inside the Function.
The Function result must return a valid structure even when no discount applies — return an empty `discounts` array rather than throwing an error or returning null.
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp