Build a Shopify Function for product discounts using Rust or JavaScript with a run.graphql input query

domain: ecommerce-ops · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Scaffold a new Shopify app with the CLI and add a product discount Function extension using `shopify app generate extension`, selecting the product discount Function type.
  2. Define your `run.graphql` input query to declare exactly which cart and product fields your Function needs — Shopify only provides fields you explicitly request in this query.
  3. Implement the `run` entrypoint (in Rust: via the `shopify_function` macro; in JS: as the default export) to receive the typed input and return a `FunctionRunResult` with a `discounts` array specifying targets and percentage or fixed-amount values.
  4. Use `shopify app dev` to run the Function locally against a development store and trigger it by adding qualifying products to a cart, inspecting the discount result via the Function tracing panel in the Partner Dashboard.
  5. Register the Function as a discount automation via the Admin GraphQL API (verify mutation name against current API docs, e.g. a variant of `discountAutomaticAppCreate`) with a title, function ID from the extension handle, and `combinesWith` settings.
  6. Test edge cases: zero-item carts, products not in scope, combine-with-other-discounts behavior, and maximum discount caps enforced by Shopify.

Known gotchas

Related routes

Create a Shopify automatic app discount backed by a deployed Shopify Function using the discountAutomaticAppCreate Admin GraphQL mutation
shopify.dev · 6 steps · unrated
Create a Shopify discountAutomaticApp (Function-backed automatic discount) via Admin GraphQL and link it to a deployed Function
shopify.dev · 6 steps · unrated
Create a Shopify discountAutomaticBxgy (buy X get Y) discount via Admin GraphQL
shopify.dev · 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