Create and deploy a Shopify Function for custom discount logic (order-level percentage off above a spend threshold) using the Discount API surface

domain: shopify.dev · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

In-depth guide

Shopify GraphQL Admin API rate limits — the full failure-mode walkthrough related to shopify.dev, checked against official docs, with linked verified routes.

Steps

  1. Scaffold a new Shopify Function with `shopify app function create`, choosing the product-discounts or order-discounts function type depending on target scope
  2. Edit the function's input query (run.graphql) to request only the cart lines, merchandise IDs, prices, and buyer identity fields your logic needs — unused fields slow compilation
  3. Implement the run function in Rust or JavaScript: read input.cart, sum line prices, and return a FunctionRunResult with an orderSubtotal FixedAmount or percentage PercentageValue discount
  4. Test locally with `shopify app function run` passing a sample JSON input; check the output JSON matches the FunctionRunResult schema before deploying
  5. Deploy with `shopify app deploy`, then create a corresponding DiscountNode (via Admin GraphQL discountAutomaticAppCreate) referencing the function's ID and configure the spend threshold as metafield configuration

Known gotchas

Related routes

Build a Shopify Function for order-level discounts that applies a percentage off the entire order
ecommerce-ops · 6 steps · unrated
Use Shopify Functions to build a custom discount on subscriptions during checkout
shopify.dev · 6 steps · unrated
Build a Shopify Function for shipping discounts that reduces or zeroes shipping line costs
ecommerce-ops · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans