Guide · 2026-12-01
Shopify Functions: what it is, how it works, and where it falls short
A Shopify Function is your code, compiled to WebAssembly, running inside Shopify's infrastructure at a fixed point in the cart or checkout flow. It receives a JSON input built from a GraphQL query you define, and returns operations: apply this discount, hide that payment method, rename this delivery option, block this checkout. There is no server of yours in the loop, no network call, and no memory between runs. That constraint set is the product.
The APIs and what each one controls
The Discount Function API handles product, order, and shipping discounts in one function, which is how tiered and combinable offers that native discounts cannot express get built. Cart Transform expands or merges cart lines, which is the bundle mechanism. Delivery Customization renames, reorders, and hides shipping options. Payment Customization does the same for payment methods. Cart and Checkout Validation blocks an order with your own error message when a rule fails.
Functions replaced Shopify Scripts, the Ruby system that was Plus-only. Public apps carrying Functions work on standard plans, which moved a whole category of checkout logic down-market. Custom apps with Functions remain a Plus feature, and that distinction decides a lot of build-versus-buy conversations.
The limits are the design brief
Shopify caps a function run at roughly 11 million instructions for carts up to 200 lines, with input and output sizes capped and the input query itself limited. Go over budget and Shopify cancels the function and applies default behaviour, meaning no discount, the full payment list, the unfiltered shipping options. The failure mode is silent and customer-facing.
That is why Shopify steers complex logic to Rust and why JavaScript functions with heavy dependencies hit the ceiling first. A function is a place for tight, deterministic rules evaluated on data already in the input. It is not a place for a pricing engine that wants to consult three external systems.
Where it falls short
No network access is the big one. A rule that depends on live inventory at a specific warehouse, a customer's current loyalty balance in an outside system, or a fraud score from a third party cannot fetch any of it. The workaround is to sync that data into metafields or customer tags ahead of time, which means the function is only as fresh as your sync.
The closed operation set is the second limit. Each API returns the operations Shopify allows and nothing else. Delivery Customization cannot create a new shipping rate, only reshape the ones a carrier service or your zones produced. When the thing you want is outside the operation set, no amount of clever code gets it back.
Related reading
For the background behind “Shopify Functions: what it is, how it works, and where it falls short”, these earlier guides help: Box-Free Label-Free Returns: What the QR Code Drop-Off Changes in Your Cost Stack, Testing Returned Electronics Without Drowning the Bench: A Triage Queue That Works, and Box-Free Label-Free Returns: What the QR Code Drop-Off Changes in Your Cost Stack.
Frequently asked questions
What is a Shopify Function?
A small program, usually written in Rust or JavaScript and compiled to WebAssembly, that Shopify runs inside its own cart and checkout flow. It reads a GraphQL-defined input and returns operations such as applying a discount or hiding a payment method.
What replaced Shopify Scripts?
Shopify Functions. Scripts were Ruby, Plus-only, and edited in a script editor. Functions ship inside apps, work on standard plans through public apps, and cover discounts, delivery and payment customization, cart transform, and validation.
What are the limits on a Shopify Function?
Roughly 11 million instructions per run for carts up to 200 lines, capped input and output sizes, no network access, and no state between runs. Exceed the budget and Shopify cancels the function and applies default behaviour.
Can a Function call my inventory or loyalty system?
No. Functions cannot make network calls. Data a rule needs has to be synced into metafields, tags, or other Shopify objects ahead of time, and the rule is only as current as that sync.