Generate a Function extension: shopify app generate extension --type product_discounts; choose Rust or JavaScript/TypeScript as the runtime
Define the function's input query in input.graphql to fetch cart.lines with sellingPlanAllocation.sellingPlan.id to detect subscription line items
In the function logic, check if a line has a sellingPlanAllocation and apply a percentage discount using the FunctionResult type with discounts array containing targets (all or specific line GIDs) and value (percentage or fixed)
Configure the function in shopify.extension.toml under [extensions.ui.handle] and deploy with shopify app deploy
Create a discount in the Shopify Admin that links to your deployed Function using the discountAutomaticAppCreate Admin GraphQL mutation with functionId
Test locally using shopify function run which allows you to provide a JSON input and inspect the FunctionResult output before deploying
Known gotchas
Shopify Functions have a strict execution time limit (5ms default budget for most function types) and a memory limit — complex logic or large input queries that exceed the budget will cause the function to return no discount silently
Function-based discounts are separate from Shopify script-based discounts; Shopify Scripts were deprecated and Functions are the replacement — they cannot coexist for the same discount type on a single checkout
The functionId in discountAutomaticAppCreate must reference the deployed (not local development) function ID — the ID changes with each deployment via shopify app deploy
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