Shopify Functions: What You Can Customise and Where They Stop
What Shopify Functions can change today in discounts, delivery, payments, validation, bundles and fulfillment, their limits, and which plans can use them.
In this guide
Shopify Functions are how you change Shopify’s own logic: how a discount is calculated, which delivery options a buyer sees, which payment methods appear, whether a cart is allowed to check out. Since Shopify Scripts ended on June 30, 2026, they are also where that kind of custom checkout logic has to live.
This guide covers what each Function API can do today, the limits every function runs under, the plan rules that decide whether you can use a custom one, and a set of example use cases. If you are moving old Scripts across, our Scripts to Functions migration guide covers that move step by step; this post is the map of what is possible.
What a function is
A function is a small piece of backend logic that Shopify runs for you at a fixed point, mostly in the cart and checkout. A few points shape everything else:
- It ships inside an app. You don’t paste a function into the admin. It is part of an app, public or custom, and the merchant turns it on, for example by creating a discount that uses it.
- It reads an input and returns operations. You declare a GraphQL input query (the cart, the buyer, metafields), Shopify passes that data in, and the function returns what to change: a discount, a hidden delivery option, a validation error.
- It is compiled to WebAssembly. Shopify provides templates for Rust and JavaScript, and strongly recommends Rust for performance.
- It runs on Shopify’s side. That is why it is fast and why it has strict limits, covered below.
Settings such as thresholds, SKU lists or customer tags usually live in metafields that the function reads through its input query, so a merchant can change behaviour without a new deploy.
What you can customise today
Shopify’s Function APIs reference lists these APIs:
| Function API | What it changes | Notes from the docs |
|---|---|---|
| Discount | Product, order and shipping discounts, code-based or automatic | Up to 25 active discount functions per store |
| Delivery Customization | Rename, sort and hide delivery options at checkout | The cheapest shipping option must stay the first one selected; up to 25 active |
| Payment Customization | Hide, rename and reorder payment methods; set payment terms; require review for B2B orders | Payment terms and B2B review are Plus-only; up to 25 active |
| Cart and Checkout Validation | Block checkout with a message when rules aren’t met, including express checkouts | Up to 25 active; POS and order edit not supported |
| Cart Transform | Expand one line into a bundle, merge lines into a bundle, update a line’s price, title or image | Update operations need Plus or a development store; one cart transform per app per store |
| Fulfillment Constraints | Require items to ship from the same location, or from a set of locations | Up to 25 active; can leave a cart with no shipping options if stock isn’t there |
| Order Routing Location Rule | Rank which location fulfills an order | Beta, Plus only, granted on request |
The reference also lists generators for local pickup and pickup point delivery options, under an unstable API path. Check their current status before planning around them.
The limits every function runs under
Functions run inside checkout, so Shopify keeps them small and fast. The resource limits are:
| Limit | Value |
|---|---|
| Compiled binary size | 256 kB |
| Runtime linear memory | 10,000 kB |
| Runtime stack memory | 512 kB |
| Logs written | 1 kB (truncated) |
| Instructions per run (carts up to 200 lines) | 11 million |
| Function input (carts up to 200 lines) | 128 kB |
| Function output (carts up to 200 lines) | 20 kB |
The last three scale up for carts with more than 200 lines.
In practice, three of these shape your design:
- Instruction count. Every line of logic and every byte of input costs instructions. JavaScript runs on an interpreter and uses far more than Rust; Shopify’s guide to optimising instruction counts covers how to stay under.
- Input size. A function that queries many collections, long metafields or every cart attribute can exceed the input limit. Ask for only the fields the rule needs.
- No outside calls by default. A function works with the data in its input. Network access through the fetch target is limited to custom apps on Enterprise stores (the Discount API docs mention Plus and Enterprise), must be requested, and is not available on development stores. If your rule depends on a live answer from an ERP or a loyalty system, plan to copy that data into metafields ahead of time instead.
Plan rules: who can use a custom function
This is the rule that decides most projects:
- Public apps with functions work on any plan. A public app distributed through the Shopify App Store can contain functions, and stores on any plan can use it (Shopify Functions).
- Custom apps with functions need Shopify Plus. Only stores on a Shopify Plus plan can use custom apps that contain Function APIs.
- Some capabilities are Plus-only on top of that, such as payment terms, B2B review requirements and cart transform update operations, as listed in the table above.
So if your store is not on Plus and you want logic only your store uses, a custom function is not available to you. Your options are to find a public app whose function does the job, to restructure the rule into something built-in discounts or Flow can do, or to move the logic out of checkout altogether. Our guide to Shopify Flow vs a custom app helps with that last choice.
One more change matters for custom apps on Plus: custom apps are now created and managed in the Dev Dashboard, and only legacy custom apps created before January 1, 2026 are still managed from the Shopify admin (Shopify Help Center).
Example use cases
These are typical rules, each mapped to the API that fits it.
| Business rule | Function API | How it works |
|---|---|---|
| Wholesale customers tagged “trade” get 15% off selected collections | Discount | Reads customer tags and line collections, returns a percentage on matching lines |
| Free shipping only above a threshold and only to one country | Discount (shipping class) | Reads cart subtotal and address, discounts the delivery line |
| Hide express delivery for oversized items | Delivery Customization | Reads a product metafield, hides the express option |
| Hide cash on delivery above a cart value | Payment Customization | Reads the cart total, hides the method |
| Limit one unit per customer of a launch product | Cart and Checkout Validation | Returns an error on the cart line when quantity is above 1 |
| Block checkout for a PO box when a product can’t ship there | Cart and Checkout Validation | Reads the address and a product flag, returns a field error |
| Sell a gift box that is three stock items | Cart Transform (expand) | Expands one line into its component variants for stock and fulfillment |
| Keep cold-chain items shipping from the one location that can pack them | Fulfillment Constraints | Requires those lines to fulfill from that location |
Each row is one function with one job. Keeping them small makes them easier to test and less likely to hit the instruction limit.
Pitfalls to plan for
- Stacking. Several discount functions, and discounts from other apps, can apply to the same cart. Decide how yours combines with them and test real combinations.
- Validation that blocks too much. A validation error stops checkout, including express checkouts. Test edge cases such as empty addresses early in checkout before turning a rule on.
- Constraints with no stock. If a fulfillment constraint points to a location that doesn’t hold the items, the buyer sees no shipping options and can’t finish.
- Logic that needs outside data. Without network access, live prices or stock from another system must be synced into Shopify first. That sync is an integration of its own; see connecting Shopify to an ERP, WMS or 3PL.
- Metafields as configuration. If settings live in metafields, decide who can edit them and how a bad value is caught.
- API versions. A function targets an API version like any other app code. Plan updates as part of maintaining a custom Shopify app.
How a function project usually runs
- Write the rule in plain words, with examples of carts that should and shouldn’t match.
- Check plan and API fit. Plus for a custom app? Is the API stable, beta or on request?
- Design the input query with only the fields the rule needs.
- Build and test locally with Shopify CLI against sample inputs, including large carts.
- Install on a development store and test real checkouts, express checkouts included.
- Add a settings screen if non-developers will change thresholds or lists.
- Turn it on for the live store, watch errors in the function logs, and keep a way to switch it off.
When to have one built
A function earns its place when the rule is specific to your business, runs in checkout, and no public app does it. If the logic doesn’t need to run during checkout, a background app or Flow is usually simpler; when to build a custom Shopify app walks through that decision. Our custom solutions page lists the plan rules we check first and what to send us.
FAQ
Can I use Shopify Functions without Shopify Plus?
Yes, through a public app from the Shopify App Store, on any plan. A custom app that contains functions can only be used by stores on Shopify Plus.
Can a Shopify Function call my own API or ERP?
Not by default. Network access is limited to custom apps on Enterprise stores (Plus and Enterprise for the Discount API), must be requested, and isn’t available on development stores. Most designs copy the needed data into metafields ahead of time.
What replaced Shopify Scripts?
Shopify Functions. Scripts stopped working on June 30, 2026, and their logic moves into functions delivered inside an app.
How many discount functions can a store use?
The Discount API docs allow up to 25 active discount functions per store. Delivery customization, payment customization, validation and fulfillment constraint functions have the same limit of 25 each.
Can Shopify Functions build product bundles?
Yes. The Cart Transform API can expand one line into its components or merge several lines into a bundle. Changing a line’s price, title or image with update operations needs Plus or a development store.