Shopify Functions Explained: Discounts, Checkout Logic and Replacing Scripts

By: Irina Shvaya | October 1, 2026
This guide is part of our Shopify resource hub: plans and fees, setup, every major feature, apps, marketing, operations, comparisons and migrations.

Shopify Functions are small pieces of custom logic that Shopify runs inside its own backend at specific points in the cart and checkout. They are how you create a discount type Shopify doesn't offer natively, hide a payment method for certain orders, rename or hide shipping options, block a checkout that breaks a business rule, or build bundles. Since Shopify Scripts stopped executing on 30 June 2026, Functions are the only supported way to customize that backend logic.

Most merchants never write a Function. They install an app from the Shopify App Store that contains one, then configure it in the admin like any other discount or checkout setting. Stores on any plan can use public apps that contain Functions. Only Shopify Plus stores can use custom apps that contain Functions, which is the route for logic built specifically for one store.

For developers, a Function is a WebAssembly module with a GraphQL input query and a JSON output. Shopify recommends Rust for performance and also supports JavaScript. Functions run under strict limits on size, memory and instructions, and they can't call external services except in limited, approved cases.

This guide explains what each Function API does, how Functions replaced Scripts, how merchants get them, and what developers need to know about limits. It is part of our Shopify resource hub.

Key Takeaways

  • Functions customize Shopify's backend logic for discounts, cart transforms, delivery and payment options, validation, fulfillment and order routing.
  • Any plan can use public App Store apps that contain Functions; custom apps containing Functions require Shopify Plus.
  • Shopify Scripts stopped executing on 30 June 2026, and the admin's Shopify Scripts customizations report maps old Scripts to Function-based replacements.
  • Most Function APIs allow up to 25 active functions per store, and Cart Transform allows one per app.
  • Functions run as WebAssembly with fixed limits, including a 256 kB compiled binary and 11 million instructions for carts up to 200 lines.

How Shopify Functions work

Every Function follows the same pattern, according to Shopify's Functions documentation:

  1. Input: you write a GraphQL input query that selects the data the Function needs, such as cart lines, product tags, customer tags or metafields. Shopify runs the query and passes the result to your code as JSON.
  2. Logic: your code, compiled to WebAssembly, decides what should happen.
  3. Output: the Function returns a JSON list of operations, such as "apply 15% to these lines" or "hide this payment method," and Shopify carries them out.

Shopify invokes Functions itself during the buyer journey. They are never called by URL. Because they run inside Shopify's infrastructure rather than on an app's server, they are fast and scale with traffic; Shopify's Help Center says the platform executes Function code in under 5 milliseconds, which is why Functions hold up during flash sales.

Merchants configure Functions through the app's settings or through native admin screens. A discount Function, for example, shows up as a new discount type when you create a discount.

The Function APIs and what each one does

As of API version 2026-10, Shopify's Function APIs reference lists these main APIs. The activation limits are from each API's reference page.

Function APIWhat it doesLimits and plan notes
DiscountCreates new discount logic for cart lines, order subtotals and shippingUp to 25 active discount functions per store
Cart TransformBundles, splits or changes how lines appear in the cartOne per app per store; update operations need Plus (or a dev store)
Delivery CustomizationRenames, reorders or hides delivery options at checkoutUp to 25 active per store
Payment CustomizationRenames, reorders or hides payment methods; can add B2B review requirementsUp to 25 active per store; some operations Plus-only
Cart and Checkout ValidationBlocks checkout when rules are broken, such as quantity limits or B2B minimumsUp to 25 active per store
Fulfillment ConstraintsControls which locations can fulfill which itemsUp to 25 active per store
Order Routing Location RuleRanks locations for routing ordersBy request, Plus only
Pickup point and local pickup generatorsGenerate pickup options at checkoutListed under the unstable API version as of October 2026

Functions run in a set order during checkout: cart transforms first, then line discounts, then fulfillment grouping and routing, delivery options and delivery discounts, payment methods, and finally validation. That order matters for developers, because a validation Function sees the cart after discounts have been applied.

One history note: in May 2025 Shopify deprecated the separate Product, Order and Shipping Discount Function APIs in favor of one unified Discount Function API. Older tutorials that use the separate APIs are out of date.

How Functions replaced Shopify Scripts

Shopify Scripts were Ruby snippets, available to Plus stores, that ran in checkout to change line items, shipping rates and payment methods. Shopify stopped allowing Script edits on 15 April 2026 and turned off all Scripts on 30 June 2026. The Help Center now says: "Any Scripts that were still published on your store have been deactivated and no longer work. To recreate these customizations, transition to Shopify Functions."

Old Script typeTypical useFunction replacement
Line item scriptsTiered pricing, buy X get Y, VIP discountsDiscount Function (or native discounts)
Shipping scriptsHide or rename rates for certain carts or addressesDelivery Customization Function
Payment scriptsHide cash on delivery or a wallet for some ordersPayment Customization Function

If your store used Scripts, open Apps, then Script Editor, and use the Replace Shopify Scripts banner. The Shopify Scripts customizations report lists the Scripts that were active before the shutdown, suggests App Store apps built on Functions for each one, and links to the relevant Function API guides. You can export it as a CSV. Many simple Scripts can now be replaced by native discounts plus one app; complex ones usually need custom work.

How merchants get Functions

There are two routes, and your plan decides which are open to you:

  • Public apps from the Shopify App Store that contain Functions. Available on every plan, subject to any Plus-only operations in a given API. Search the App Store for the job you need, such as tiered discounts, payment method rules or shipping rules.
  • Custom apps built for your store. Only Plus stores can use custom apps that contain Function APIs. Shopify also notes that Function-based apps require App Bridge, and custom apps created in the Shopify admin don't support it, so custom Function apps must be created in the Dev Dashboard and then connected to your store.

When you evaluate a Function-based app, look for the Built for Shopify badge, check how recent the reviews are, confirm whether pricing is flat or usage-based, and test the app with your largest realistic cart before a sale. Also check how many functions it activates, because the 25-per-API cap is shared across all apps on your store. For the broader decision, see Shopify apps vs Shopify Functions and our explainer on public vs private Shopify apps.

For developers: building a Function

Functions live inside an app as extensions. With Shopify CLI you scaffold one with shopify app generate extension, choose the Function API, and get a configuration file (shopify.extension.toml), a GraphQL input query, a schema file and a starter in Rust or JavaScript. Set the api_version to the latest supported version (2026-10 as of October 2026), and regenerate the schema with the CLI when you upgrade.

Merchant-configurable settings usually come from metafields that your Function reads in its input query, often with an admin UI extension for editing them. Function APIs are versioned quarterly like the rest of Shopify's APIs.

Resource limits

Shopify publishes these limits for all Functions:

ResourceLimit
Compiled binary size256 kB
Runtime linear memory10,000 kB
Runtime stack memory512 kB
Execution instructions (carts up to 200 lines)11 million
Function input (up to 200 lines)128 kB
Function output (up to 200 lines)20 kB
Input query size3,000 bytes, maximum calculated cost of 30

The dynamic limits scale proportionally for carts over 200 lines. Shopify strongly recommends Rust to avoid failures on large carts. A few other rules: no randomness or clock access (Functions must be deterministic), no debugging through standard output, and apps can only reference their own Functions in Admin API mutations. The App Store also doesn't permit apps that let merchants edit and run Function code dynamically.

Network access

By default a Function can't call an outside service. Some APIs offer a fetch target, where Shopify makes an HTTP request on your behalf before the Function runs, but access is limited (for example, to custom apps on Plus and Enterprise stores for discounts) and must be requested. For most use cases, pass data in through metafields or cart attributes instead.

If you are hiring for this work, our guide to hiring Shopify app developers covers what to ask about Functions experience.

Common use cases worth knowing

  • Tiered "spend more, save more" discounts and buy-more-save-more pricing.
  • Hiding cash on delivery above an order value, or hiding a wallet for subscription orders.
  • Renaming shipping rates to show delivery dates, or hiding express shipping for oversized items.
  • Enforcing purchase limits per customer during a product drop.
  • B2B order minimums, maximums or credit limits per company location.
  • Bundles that show as one line but fulfill as separate SKUs.

Conclusion

Shopify Functions are the backbone of checkout customization in 2026. Merchants on any plan can use them through public apps, and Plus stores can commission custom Functions for logic no app covers. If you migrated from Scripts, use the customizations report to confirm nothing was lost. If you need a custom Function or a private app built around one, our Shopify app development team builds and maintains them.

Frequently asked questions

Do I need Shopify Plus to use Shopify Functions?

No. Any plan can use public App Store apps that contain Functions. Plus is required only for custom apps that contain Functions and for certain Plus-only operations within some APIs.

Are Shopify Scripts still available?

No. Scripts stopped executing on 30 June 2026. Recreate them with Function-based apps or custom Functions, using the Shopify Scripts customizations report as a checklist.

What languages can I write Functions in?

Any language that compiles to a WebAssembly module meeting Shopify's requirements. Shopify provides templates for Rust and JavaScript and strongly recommends Rust for performance.

How many discount Functions can a store run?

Up to 25 active discount functions per store. Delivery customization, payment customization, validation and fulfillment constraint functions each have the same 25-per-store limit.

Can a Shopify Function call my own API?

Generally no. Network access through a fetch target is limited to certain APIs and store types and must be requested. Most Functions read data from metafields or cart attributes instead.

Put this into action with eSEOspace

We help businesses grow with website design that actually performs. Explore the services behind this guide:

Book a free strategy call →

Get a FREE Audit

We'll perform a comprehensive SEO, AEO, GEO & CRO audit of your website — completely free — and show you exactly how to outrank your competitors.

Don't have a site yet? Get in touch →

Get a FREE GEO/AEO/SEO Audit

We'll analyze your site's SEO, GEO, AEO & CRO — completely free — and show you exactly how to get found across Google and AI answers.

Don't have a site yet? Get in touch →

You Might Also like to Read