A Shopify discount function is app code that Shopify runs inside its own checkout to work out a discount. It’s how apps add discount types Shopify doesn’t offer by default, like tiered quantity breaks. You never touch the code. You install the app, create the offer, and Shopify does the math every time the cart changes.
This guide explains what discount functions are, how they behave next to your regular discounts, and what to check before you trust one with a sale. For the wider picture on bundle offers, start with our product bundles guide.
What is a Shopify discount function?
Shopify Functions are small programs that let apps change parts of Shopify’s backend logic. A discount function is the type that calculates discounts. Shopify’s developer docs put it simply: Functions let apps “create discount functionality that isn’t offered out of the box with Shopify” (Shopify.dev).
Shopify gives two examples of what that means:
- One discount that cuts a product price and a shipping rate at the same time.
- Volume discounts with different rates when a line item quantity hits set thresholds.
The second one is exactly what a quantity break offer is. Shopify’s built-in discount types can’t give 10% off 2 items, 15% off 3 and 20% off 4 in a single discount. A function can.
How does a discount function work at checkout?
You don’t need to know any code, but the flow helps when you troubleshoot. Shopify describes the lifecycle in four steps (Shopify.dev):
- A developer builds an app that contains a function and defines a new discount type.
- You install the app and configure the discount, for example your tiers and products.
- The app saves that setup to Shopify as a discount.
- Shopify runs the function when customers interact with your store, such as adding a product to the cart.
Two details matter for merchants:
- It runs on Shopify, not on the app’s server. Shopify says functions are “never invoked directly by URL” and are run “as-needed within the customer journey.” The discount doesn’t depend on a script loading in your theme.
- It shows up in your admin. A function-backed discount is a real Shopify discount. Apps create it as an “app” discount, either automatic or code-based, so it sits in your Discounts list next to the ones you made yourself.
What is the difference between Shopify Functions and other discounts?
Here is how the main options compare, based on Shopify’s developer docs:
| Built-in Shopify discount | App discount (discount function) | |
|---|---|---|
| Who creates it | You, in Discounts | An app, from its own discount type |
| Types | Amount off products or orders, buy X get Y, free shipping | Whatever the app’s function supports, such as tiered quantity pricing |
| Method | Automatic or code | Automatic or code |
| Where the logic runs | Shopify | Shopify, using the app’s function |
| Follows combination rules | Yes | Yes |
| Plan needed | Any | Any, for public App Store apps |
The plan row is a common worry. Shopify says “stores on any plan can use public apps that are distributed through the Shopify App Store and contain functions.” Only custom apps with Shopify Function APIs are limited to Shopify Plus, and some specific capabilities are Plus-only (Shopify.dev).
What can a discount function change?
A discount can target three parts of the cart. Shopify calls them discount classes (Shopify.dev):
| Class | What it reduces |
|---|---|
| Product | Specific cart lines |
| Order | The order subtotal |
| Shipping | Shipping rates |
Shopify’s Discount Function API lets a single function apply savings across all three. Shopify’s example is one discount that reduces both the order total and delivery costs (Shopify.dev). Most discount function apps stick to one class, though. A quantity break, for example, is a product discount.
What are the limits of discount function apps?
Functions are powerful, but they have rules. These are the ones merchants run into most.
The 25-function cap
Shopify’s Discount Function API docs say: “You can activate a maximum of 25 discount functions on each store” (Shopify.dev). If you run lots of app offers, plus a few seasonal ones, you can hit that ceiling. Turn off offers you no longer use, or merge similar offers into one.
Functions don’t know about each other
Shopify notes that “all discount functions run concurrently, and have no knowledge of each other.” Each one proposes its discount. Shopify then combines those candidates following the combination settings on each discount. So stacking is decided by your settings, not by the apps talking to each other.
That means a function discount and your WELCOME10 code only stack if both allow the other’s class. Our Shopify discount combinations guide walks through the rules and the math.
Not every surface supports them
Shopify publishes a compatibility list for the Discount Function API. Cart, checkout, the storefront, accelerated checkout, B2B and POS are listed as supported. A few are not (Shopify.dev):
| Surface | Support | What Shopify says |
|---|---|---|
| Order edits in the admin | Not supported | Listed as not supported |
| Order edits in checkout | Partial | The function isn’t re-run when editing an order |
| Draft orders | Partial | Functions with network access aren’t supported |
| Subscription recurring orders | Partial | The function isn’t re-run when recurring orders are created |
| Create Order API | Not supported | Listed as not supported |
| Pre-order and Try Before You Buy | Not supported | Listed as not supported |
If you sell subscriptions or edit orders often, test how your discounted orders behave before a launch.
How do bundle apps use Shopify Functions?
Bundle apps usually need two kinds of functions, because “discount the price” and “sell several products as one” are different jobs.
- Discount functions handle price drops on cart lines, like quantity breaks and buy X get Y deals.
- Cart Transform handles bundles. Shopify says that to change how cart items look, including “changing prices, and bundling items,” you can only use the Cart Transform API. It can expand a bundle line into its products or merge lines into one bundle (Shopify.dev).
Shopify also notes a store can have one cart transform function per app. If more than one app on your store has one, all of them run. That’s worth knowing if you use two bundle apps at once.
Our own app, Sam Bundles, uses both. Quantity breaks and buy X get Y offers run as a Shopify Function. When the cart matches a tier, the discount appears in the cart and at checkout under the name you set. Bundle builder, fixed bundle and mix and match offers go through Cart Transform, which splits the bundle into its products at their bundle prices.
For a broader look at what apps add on top of Shopify’s own bundle tools, see Shopify bundles: app vs native.
How do you set up a function-based discount?
You set it up in the app, not in code. The exact screens depend on the app. Here is the flow for a quantity break in Sam Bundles, from the quantity breaks setup guide:
- Install the app and turn on its app embed.
- Click Create new offer and pick the quantity breaks template.
- Choose the products and set your bars, for example buy 2 for 10% off and buy 3 for 15% off.
- In Settings, set the Discount name. This is the label shoppers see in the cart and at checkout.
- In Advanced, tick which classes the offer can combine with: Product discounts, Order discounts or Shipping discounts. You can also limit who gets it, such as customers with specific Customer tags.
- Optionally switch on Schedule, set a Start date and tick Set end date.
- Click Save, then test a real cart with and without your usual codes.
The schedule, eligibility and combination options are explained in the offer settings guide. If you’re still choosing tiers, our guide to quantity breaks on Shopify covers the pricing side.
What should you check before installing a discount function app?
A short checklist saves a lot of checkout surprises:
- Count your active discount functions. You have 25 slots per store, shared across apps.
- Set combinations on purpose. Decide which offers stack with codes and free shipping, and set both sides to match.
- Check the discount label. Make sure the name shoppers see at checkout explains the deal clearly.
- Test on the surfaces you use. Try the cart, checkout, POS and accelerated checkout if you offer them. Check subscription and edited orders separately.
- Watch for overlapping apps. Two apps discounting the same products can confuse shoppers and stack in ways you didn’t plan.
- Look at margin on the combined deal. A 15% tier plus a 10% code is a bigger cut than either one alone.
And keep the offer honest. A tiered price that’s always on is fine. A fake “ends tonight” timer on a discount that never ends isn’t.
Where should you start?
If you only need simple sales, Shopify’s built-in discounts cover a lot. Read automatic discounts vs codes to choose between them.
When you need tiered pricing, BOGO tiers or bundles that discount automatically, a discount function app is the standard way to get there on Shopify. Pick one, set your combinations, test a few carts, and launch.
Frequently asked questions
What is a Shopify discount function?
It is a small piece of app code that Shopify runs inside its own checkout logic to calculate a discount. Apps use it to add new discount types, such as tiered volume discounts. After you install the app, you create discounts from those types and Shopify runs the function when buyers add products to the cart.
Do I need Shopify Plus to use a discount function app?
No. Shopify says stores on any plan can use public apps from the Shopify App Store that contain functions. Only custom apps with Shopify Function APIs are limited to Shopify Plus, and some individual capabilities are Plus-only.
How many discount functions can a Shopify store run?
Shopify's Discount Function API documentation says you can activate a maximum of 25 discount functions on each store. Each active app discount counts, so review old offers before a big sale.
Do discount functions stack with my discount codes?
Only if both sides allow it. Shopify combines discounts from functions in line with the combination settings on each discount. If a function discount and a code don't allow each other's class, they won't apply together.
Does Sam Bundles use a discount function?
Yes. Quantity breaks and buy X get Y offers in Sam Bundles run as a Shopify Function, so the discount appears in the cart and at checkout under the name you set. Bundle builder, fixed bundle and mix and match offers use Shopify's Cart Transform instead.
Sources
Part of our guide: Product bundles →