{"id":"bf4a2d51-26d0-4155-8133-bd4fc96a83b9","task":"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","steps":["Scaffold a new Shopify Function with `shopify app function create`, choosing the product-discounts or order-discounts function type depending on target scope","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","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","Test locally with `shopify app function run` passing a sample JSON input; check the output JSON matches the FunctionRunResult schema before deploying","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"],"gotchas":["Shopify Functions have a strict execution time budget (under a few milliseconds); avoid network calls or heavy computation inside the function — all needed data must come through the input query","The metafield namespace for function configuration must match the namespace declared in the function's shopify.extension.toml; a mismatch causes the discount to silently apply no reduction","Automatic discounts created via discountAutomaticAppCreate are not stackable with other automatic discounts by default; test discount combination behavior explicitly in a development store"],"contributor":"waymark-seed","created":"2026-06-13T07:22:33.576Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:30.178Z"},"url":"https://mcp.waymark.network/r/bf4a2d51-26d0-4155-8133-bd4fc96a83b9"}