Guide · 2026-12-01
Shopify Functions: what it is, how it works, and where it falls short
Shopify Functions are small WebAssembly programs that run inside Shopify's own infrastructure and change how checkout behaves: discounts, cart transformations for bundles, which delivery and payment options appear, and whether a cart is allowed to check out at all. They replaced Shopify Scripts as the way to write custom logic, and they trade the old freedom for hard resource limits and a sandbox with no network, no clock and no randomness.
What a Function can actually change
The discount API applies product, order and shipping discounts in one pass. Cart transform expands one line into bundle components or merges lines into a bundle. Delivery and payment customization hide, rename or reorder options that already exist. Validation blocks checkout with your own error message when a rule fails, including in express checkout. That is a wide surface, and it covers most of what stores used Scripts for.
Notice what is missing: no creating delivery rates, no calling an outside service for a price, no remembering anything between runs. A Function is a pure calculation over the cart it is handed. Design that treats it as one works; design that treats it as a small server does not.
Where Functions fall short
The limits are the honest answer. Twenty kilobytes of output does not support bulk price changes across every line of a huge cart. Eleven million instructions sounds like plenty until a discount rule walks a 200-line cart with nested conditions. And when a Function exceeds its budget, Shopify cancels it and applies default behavior. No error page, no alert: the discount just is not there.
The plan gate matters too. A custom app with Functions is a Plus feature, so a non-Plus store is choosing among public apps, with their configuration models, not commissioning bespoke logic.
Configuration belongs in metafields
The pattern experienced teams use: thresholds, tier tables and product groupings live in metafields read by the input query, not compiled into the binary. Changing a tier then means editing data, not deploying code. It also keeps the input query honest, because you can see exactly what the Function knows. The 3,000-byte query cap punishes greed here; ask for the fields the rule needs and no more.
The specifics that decide it
- Functions are compiled to WebAssembly and run on Shopify's infrastructure. The documented limits for carts up to 200 lines are 11 million execution instructions, 128 kB of input and 20 kB of output, with a compiled binary cap of 256 kB.
- The input query is capped at 3,000 bytes with a maximum calculated cost of 30, and metafield values over 10,000 bytes are not returned.
- Separate Function APIs cover discounts, cart transform, delivery customization, payment customization and cart and checkout validation, among others.
- A store can have at most 25 active discount Functions, and delivery customization can hide, rename or reorder existing rates but cannot create new ones.
- Custom apps containing Functions are limited to Shopify Plus stores, while public apps can bring Functions to other plans. Functions cannot use clocks or randomness; time-dependent values must be passed in as data.
Hold onto the first and last of those in particular. Functions are compiled to WebAssembly and run on Shopify's infrastructure. The documented limits for carts up to 200 lines are 11 million execution instructions, 128 kB of input and 20 kB of output, with a compiled binary cap of 256 kB. While at the other end: Custom apps containing Functions are limited to Shopify Plus stores, while public apps can bring Functions to other plans. Functions cannot use clocks or randomness; time-dependent values must be passed in as data. Between those two facts sits every sensible decision about Shopify Functions, and most of the expensive ones come from planning as if one of them were not true.
Related reading
Readers working through “Shopify Functions: what it is, how it works, and where it falls short” often find these earlier guides useful as well: Instant Refunds: The Money Leaves Before the Box Arrives, Serial Capture at the Sale Stops the Switch at the Counter, and Bracketing Is Not Fraud, But You Can Still Price Its Cost.
Frequently asked questions
What are Shopify Functions used for?
Server-side checkout logic: discounts no form can express, bundle handling through cart transform, hiding or reordering delivery and payment options, and validation rules that block a cart. They run as WebAssembly on Shopify's infrastructure at defined extension points.
What are the resource limits for a Function?
For carts up to 200 lines, Shopify documents 11 million execution instructions, 128 kB of input and 20 kB of output, with a 256 kB compiled binary cap. The input query is limited to 3,000 bytes at a calculated cost of 30. Exceeding a limit means the Function is cancelled and default behavior applies.
Can a Function call an external service?
Not in the normal model. Functions are pure calculations over the input they are given, with no clock and no randomness. Data the rule needs, including time-dependent values, has to be passed in through the input query, usually from metafields.
Do Shopify Functions require Shopify Plus?
Custom apps containing Functions are limited to Plus stores. Public apps can deliver Functions on other plans, which means choosing from an app's configuration model rather than commissioning bespoke logic.