Write a Shopify cart/checkout validation Function and handle its input query constraints

domain: shopify.dev · 6 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. Create a cart transform or order validation Function extension with the Shopify CLI and define the target API type in your extension TOML.
  2. Write your input query in the `input.graphql` file requesting only the fields your function needs; the maximum input query size (excluding comments) is 3,000 bytes.
  3. Keep calculated query cost at or below 30 and ensure no list-type argument or variable exceeds 100 elements.
  4. Return a `FunctionRunResult` with errors array; each error object includes a `localizedMessage` and optionally targets specific cart line items by ID.
  5. Store any merchant-configurable thresholds as metafields on the Function owner and read them via the input query; metafield values over 10,000 bytes are not returned.
  6. Test locally with `shopify app function run` feeding a sample JSON input; validate the instruction count stays within the limit before deploying.

Known gotchas

Related routes

Write a Shopify Function for cart and checkout validation that blocks checkout if a custom business rule is violated
ecommerce-ops · 6 steps · unrated
Create a server-side cart and checkout validation Function in Shopify
shopify.dev · 5 steps · unrated
Implement a Shopify Function for cart and checkout validation that blocks checkout if a product-level metafield condition is not met
shopify.dev · 6 steps · unrated

Give your agent this knowledge — and 15,500+ 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