RelevanceRail
Product recommendations shoppers actually want

Shopify Functions: what it is, how it works, and where it falls short

The demo looked simple, and for the first week Functions usually does look simple. Then the edge cases arrive: the orders it does not apply to, the customers it quietly excludes, the report that does not match.

Shopify Functions are small pieces of your own logic that Shopify runs inside its own checkout pipeline. You write a GraphQL input query that selects cart, customer and product data, compile your code to WebAssembly, and return operations: apply this discount, hide that delivery option, block this checkout. The function runs on Shopify's infrastructure at a fixed point in the flow, so its answer cannot be bypassed from the browser.

How it actually works

For carts up to 200 line items a function gets 11 million execution instructions, 128 kB of input and a compiled binary limit of 256 kB. Functions cannot use clocks or randomness; anything time-dependent has to arrive as input data, because the same input must always produce the same output.

For the search side of Functions, see Your Click Data Is Lying About Relevance, Politely.

Where Functions falls short

Functions fall short anywhere the logic needs the outside world. There is no network call to your warehouse system, no live inventory service, no CRM lookup; if the data is not in the input query or a metafield, the function cannot see it. The output budget also rules out bulk price transformations across every line of a huge cart.

Shopify provides Rust and JavaScript templates and strongly recommends Rust, which avoids failures on large carts. The documented APIs cover discounts, cart transform, delivery customization, payment customization, validation, fulfillment constraints and order routing.

What to measure before you commit

Test against the biggest carts your store actually produces, not a three-line demo cart, because instruction limits bite at scale. In production, watch for the silent failure mode: when a function errors or exceeds its budget, Shopify falls back to default behavior, so a broken discount function looks like a quiet week, not an outage.

A store can run up to 25 active discount functions, and discount functions follow Shopify's combination rules when several apply at once. There is a companion argument in Typo Tolerance and Tokenisation: How Site Search Reads a Query Before It Ranks Anything worth reading alongside this one, especially if Functions is already live on your store.

Writing the function is the small part. The real cost is the discipline: versioned deploys through an app, staging against real cart shapes, and someone on the team who can read the execution logs when a promotion misbehaves on a Saturday. Custom apps containing Function APIs are gated by plan, which is why the same app can behave differently on two stores.

Frequently asked questions

Do Shopify Functions replace Shopify Scripts?

Yes. Scripts were Ruby, Plus-only and stopped running on June 30, 2026. Functions are the replacement for discount, shipping and payment logic, and they run sandboxed with hard limits Scripts never had. A Script cannot be converted automatically; the logic has to be rewritten.

What happens when a function hits its limits?

Shopify cancels the execution and applies default behavior: no discount, the full payment list, the unmodified delivery options. Nothing errors on the customer's screen, which is why monitoring matters more than the code itself.

What does Functions cost a store, all-in?

Writing the function is the small part. The fee on the pricing page is usually the smallest part of that number, and judging the category on the fee alone is how stores end up surprised in the second quarter.

What is the first thing to get right with Functions?

The mechanism, before the optimization. For carts up to 200 line items a function gets 11 million execution instructions, 128 kB of input and a compiled binary limit of 256 kB. Stores that start there argue about settings later, from data. Stores that skip it argue about opinions, from dashboards nobody trusts.