ReturnWarden

Mistakes · 2026-12-01

Common Shopify Functions mistakes that waste money or cause problems

Most Shopify Functions failures are silent, which is what makes them expensive. Exceed the instruction budget on a big cart and the discount simply does not apply. Assume a clock or a network call and the logic is wrong from the first run. The mistakes below share a shape: treating a constrained sandbox like a normal backend, then discovering the difference from a customer's screenshot.

The facts underneath the failures

Testing only on small carts

A Function gets 11 million instructions for carts up to 200 lines, and the budget is per run. Logic that loops over lines and metafields can pass every demo and fail on the one B2B order that matters, applying no discount and showing no error.

Assuming network access or a clock

Functions run in a sandbox with no network calls in the normal model and no clock or random functions. Anything time-based, a sale window, a daily cap, has to arrive as input data. Code written against a normal backend's assumptions is wrong in ways tests may not catch.

Trying to create delivery rates

Delivery customization hides, renames and reorders rates Shopify or a carrier service already calculated. It cannot invent a rate. Stores that scope a Function to produce a custom freight price discover this at build time, expensively.

Hard-coding the tier table

Compiling thresholds into the binary means every commercial change waits on a developer and a deploy. Within a quarter the table is stale, staff hand out manual codes instead, and the Function becomes expensive decoration.

Two facts explain why these particular failures keep recurring. 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. And: 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. Programs built in ignorance of the first and in denial of the second do not need bad luck to fail; the calendar is sufficient.

Related reading

Readers working through “Common Shopify Functions mistakes that waste money or cause problems” often find these earlier guides useful as well: The Double Dip: A Refund Collected Twice, Once at the Counter and Once at the Bank, The Refund Delay Message: Wording That Cuts Tickets in Half, and Bracketing in Footwear Is a Fit Data Problem Before It Is a Fraud Problem.

Frequently asked questions

Why did our discount Function work in testing and fail live?

Cart size is the usual cause. The instruction budget is per run and limits are documented for carts up to 200 lines; a rule that is cheap on a 3-line test cart can exceed the budget on a large real order, and failure is silent default pricing.

Why does our Function give inconsistent results?

Check for assumptions the sandbox forbids: clocks, randomness, network data. Functions cannot use them, so time windows or live prices baked into the logic behave unpredictably. Pass those values in as data through the input query.

Can we stack one Function per promotion?

Up to a point: 25 active discount Functions is the cap, and combination behavior is governed by each discount's combinations setting. A Function per promotion also multiplies the silent-failure surface. Fewer, well-tested Functions age better.

What is the most overlooked Functions limit?

The 20 kB output cap. It rules out bulk price transformations across every line of a large cart. Designs that rewrite all line prices hit it exactly when the cart is biggest, which is when the discount matters most.