# Shopify discount Functions for production stores in 2026

Discount Function API: product, order, and shipping classes, discountAutomaticAppCreate, combination rules, 25-function cap, and failed-run behaviour after Scripts sunset.

- Date: 2026-11-26
- Category: Shopify

## Table of contents

- Why Shopify discount Functions matter in 2026
- How Discount Functions run in production
- Production checklist for Shopify discount Functions
- What breaks when Shopify discount Functions go wrong
- How to measure Shopify discount Functions
- Related work on this site
- FAQ
  - What are Shopify discount Functions in checkout?
  - How do Shopify discount Functions differ from Shopify Scripts?
  - How many Shopify discount Functions can a store activate?
  - What happens when a Shopify discount Function run fails?

Shopify discount Functions are how I replace brittle Scripts-era price rules with one server-side discount that can touch product lines, order subtotals, and shipping in a single checkout run. I am Alan Vo, a Gold Coast web developer with 18 years in production. When merchandising wants tiered spend thresholds, line-level exclusions, or a code that only applies when a cart attribute is set, the documented stack is the [Discount Function API](https://shopify.dev/docs/api/functions/latest/discount) paired with automatic or code discounts created through the Admin GraphQL API.

This note is for developers and commercial leads who still juggle Shopify native discounts, legacy app rules, and [Shopify checkout extensibility](https://alanvo.com/blog/shopify-checkout-extensibility/) migrations. It covers discount classes, `cart.lines.discounts.generate.run` versus delivery targets, combination rules, the 25 active function cap, soft failure when a run errors, and how discount Functions sit after [Shopify cart transform](https://alanvo.com/blog/shopify-cart-transform-functions/) in the pipeline.

## Why Shopify discount Functions matter in 2026

Shopify discount Functions matter because checkout is where margin leaks when three unrelated apps each try to own price. Native percentage-off codes cannot exclude engraved lines, cap combined savings, or rename shipping tiers without workarounds. Shopify Scripts are gone on modern checkout timelines. The unified Discount Function API lets one installed app express product, order, and shipping operations from a single discount node, aligned with how Shopify documents [discount methods](https://shopify.dev/docs/apps/build/discounts) for automatic and code-based promotions.

Each store can activate up to 25 discount functions at once, and Shopify runs them concurrently with no awareness of peer functions. Candidates combine only when merchants configure [discount combinations](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) on each discount. That concurrency is powerful for modular apps, but painful when two vendors both emit order-level candidates on the same cart.

Discount classes are not decorative labels. Shopify maps `PRODUCT`, `ORDER`, and `SHIPPING` to the targets your function implements. Product and order savings flow through `cart.lines.discounts.generate.run`. Shipping savings use `cart.delivery-options.discounts.generate.run`. When you create discounts with `discountAutomaticAppCreate` or `discountCodeAppCreate`, you must set `discountClasses` to match what the function returns. A mismatch yields silent non-application or GraphQL user errors at create time.

From API version 2025-10 onward, Shopify expects stable function handles instead of querying function IDs across environments. That small change speeds CI promotion when the same app moves from staging to production.

The Discounts Allocator Function developer preview ended on 10 September 2026 without a GA release, per Shopify's discounts documentation. Do not plan new work against allocator APIs. Discount Functions own candidate generation; combination policy stays on the discount node.

![Shopify discount Functions on a laptop showing a Shopify storefront layout](../../images/blog/shopify-discount-functions-1.jpg)

## How Discount Functions run in production

Discount Functions run at checkout (and on supported surfaces such as cart, storefront accelerated checkout, B2B checkout, and POS) when a buyer's cart matches an automatic discount's prerequisites or when they enter a valid code tied to an app discount type.

Scaffolding starts with Shopify CLI. The documented command is `shopify app generate extension --template discount`. You configure targets in `shopify.extension.toml`, implement logic in Rust or JavaScript, and shape input with a GraphQL query that requests only fields the algorithm needs. Over-fetching cart metafields slows every checkout.

Creating the merchant-facing discount is an Admin API step. For automatic promotions, `discountAutomaticAppCreate` requires the `write_discounts` scope and supplies `functionHandle` plus `discountClasses`. For codes, `discountCodeAppCreate` follows the same pattern with customer-facing strings. Shopify's [build a Discount Function](https://shopify.dev/docs/apps/build/discounts/build-discount-function) tutorial walks through volume pricing with metafield configuration stored on the discount or products.

At runtime, Shopify passes cart lines, costs, buyer identity, and discount configuration into the run target. Your function returns ordered discount operations. Shopify applies them according to combination rules. Cart transform, when present, has already reshaped lines. Discount Functions price the structure buyers see, which is why bundle merchandising must stabilize transform rules before you tune tiered discounts on component SKUs.

Network access through the fetch target remains limited. Shopify documents fetch for custom apps on enterprise stores with approved network access. Do not assume live ERP lookups on every development store. Draft orders partially support discount Functions but not network-backed runs, which matters for B2B invoice checkout tests.

Failure behaviour is soft by design. If a discount Function run fails, Shopify discards that run's output, does not apply that discount, and lets checkout continue. There is no `blockOnFailure` knob like cart validation or cart transform. Operations teams must monitor function error rates because buyers may check out at full price without a visible error when logic throws.

Recurring orders are a partial surface. Shopify does not re-run the function on subscription renewals, and shipping discounts from the origin order can default to full shipping off on recurring shipments. Subscription-heavy catalogues need explicit QA on first order versus renewal pricing.

## Production checklist for Shopify discount Functions

The production checklist orders data, app configuration, merchant admin setup, and cross-surface tests before you flip an automatic discount live on a sales window.

1. Inventory every active discount: native automatic, native codes, legacy Scripts replacements, and third-party apps. Map which ones target product, order, or shipping.
2. Confirm you are under the 25 active discount function cap across installed apps. Deactivate obsolete functions before adding a new vendor.
3. Scaffold the discount extension with the smallest input query that still encodes your rules. Document which metafields merchandising must maintain.
4. Implement product and order candidates on `cart.lines.discounts.generate.run` only if those classes are required. Add the delivery target only when shipping tiers need custom logic.
5. Set `discountClasses` on create mutations to the exact set of classes the function emits. Include `SHIPPING` only when delivery operations exist.
6. Store configuration in discount metafields or product metafields using namespaces your app owns. Avoid hard-coded variant ID lists in source when metafields can drive tier tables.
7. Configure combination rules on each app discount so stacking matches finance policy. Product plus order plus free shipping stacks are not automatic.
8. Migrate off function ID lookups to `functionHandle` in deployment scripts for API 2025-10 and later.
9. Test automatic discounts on an empty cart, a one-line cart, and a cart that should be excluded by property or tag rules.
10. Test code discounts with case sensitivity, usage limits, and buyer segments if you use Shopify's native code settings alongside app logic.
11. Test checkout after [Shopify cart transform](https://alanvo.com/blog/shopify-cart-transform-functions/) changes bundle line shapes. Discount percentages should apply to the post-transform lines merchandising expects.
12. Test POS and accelerated checkout if those channels contribute meaningful revenue. Compatibility is broad but not universal for pre-order and try-before-you-buy flows.
13. Test draft order invoice payment flows without fetch/network if your function uses local data only.
14. Pair marketing dates with discount `startsAt` and `endsAt` in Admin API payloads so timezone mistakes do not open early.
15. Brief support on soft failure: if the app errors, the discount simply will not apply.

![Clothing rails in a shop used as a live catalogue for Shopify discount Functions](../../images/blog/shopify-discount-functions-2.jpg)

## What breaks when Shopify discount Functions go wrong

The first break is `discountClasses` that do not match function output. Merchants see a healthy discount node in admin while checkout never reduces price. Fix by aligning Admin API input with the targets implemented in `shopify.extension.toml`, then recreate or update the discount.

The second break is stacking two order-level app discounts that merchants marked combinable. Buyers see deeper savings than finance approved. Fix combination flags and retire duplicate apps.

The third break is discounting lines that cart transform just merged or expanded. Tier rules keyed on parent variant IDs misfire on component lines. Fix transform rules first, then encode discounts against the line shape post-transform.

![Theme code on a monitor during Shopify discount Functions work](../../images/blog/shopify-discount-functions-3.jpg)

The fourth break is relying on cart attributes set only from a checkout UI extension without writing the same attribute on storefront cart. The function input lacks the trigger. Fix attribute writers across cart and checkout surfaces.

The fifth break is silent function exceptions during peak traffic. Checkout succeeds at full price and marketing blames the theme. Add staging replay tests and monitor partner function logs. Treat sustained error spikes as P1 because there is no hard block.

The sixth break is shipping logic on subscription renewals. Promised recurring shipping rates diverge from first order. Document renewal behaviour with finance and adjust native shipping profiles where Functions cannot re-run.

## How to measure Shopify discount Functions

Measurement pairs finance truth with engineering signals. I export order discount applications for SKUs covered by the new function for two weeks before and after launch. Compare average order discount dollars, count of orders with zero applied discount when a code was entered, and refund rates tagged as pricing disputes.

In staging, log each candidate your function returns for fixture carts. In production, sample fifty checkout completions daily during a campaign and verify discount titles match the app discount node shoppers expect.

Track redemption for code-based functions separately from automatic ones. A spike in abandoned checkouts after code entry often means validation logic rejects valid carts.

For combination policy, run a matrix test: cart with native free shipping plus app product discount plus app order discount, marking each combination on or off. Finance should sign the matrix before Black Friday.

Document function version deploys beside merchandising metafield imports. When tier tables change the same hour as a new app release, you need correlation IDs in Slack, not guesswork.

## Related work on this site

Discount and checkout logic shows up on the Fashion and lifestyle stores I ship. [Their Nibs](https://alanvo.com/work/their-nibs/) needed cart and checkout clarity alongside measured conversion gains on published work. [Tamannaah Fine Jewellery](https://alanvo.com/work/tamannaah-fine-jewellery/) and [Offporter](https://alanvo.com/work/offporter/) are reminders that promotion rules only work when catalogue data, ops, and checkout extensibility move together.

If you are still mapping Scripts retirement, read [Shopify checkout extensibility](https://alanvo.com/blog/shopify-checkout-extensibility/) and bundle line behaviour in [Shopify cart transform](https://alanvo.com/blog/shopify-cart-transform-functions/) before you tune discount tiers on kit SKUs.

## FAQ

### What are Shopify discount Functions in checkout?

Shopify discount Functions are app extensions that calculate custom automatic or code-based discounts at checkout. Each function attaches to one discount node but can return product, order, and shipping operations according to its configured discount classes. Shopify runs the function when cart prerequisites match automatic rules or when a buyer applies a linked discount code.

![Phone showing a product page in Shopify discount Functions testing](../../images/blog/shopify-discount-functions-4.jpg)

### How do Shopify discount Functions differ from Shopify Scripts?

Shopify discount Functions replace Scripts-era custom discount logic inside checkout extensibility. They run as deployed app functions with GraphQL-defined input, use discount classes tied to Admin API discount nodes, and respect Shopify's 25 active function limit. Scripts depended on legacy checkout assets that Shopify is sunsetting in favour of Functions and UI extensions.

### How many Shopify discount Functions can a store activate?

Shopify discount Functions are capped at 25 active functions per store, per the Discount Function API reference. All active functions run concurrently without knowing about each other. Merchants control whether candidates combine through per-discount combination settings.

### What happens when a Shopify discount Function run fails?

When a Shopify discount Function run fails, Shopify discards that function's output, does not apply that discount for the checkout attempt, and allows the buyer to continue. Discount Functions do not expose `blockOnFailure`. Monitoring and staging tests are the guardrails because buyers may complete purchase at undiscounted prices without an on-screen error.


![Card payment at a counter after a Shopify discount Functions release](../../images/blog/shopify-discount-functions-5.jpg)


HTML version: https://alanvo.com/blog/shopify-discount-functions/
