Shopify Plus

Custom Discount Logic With Shopify Functions

Custom Discount Logic With Shopify Functions

Discounts and promotions are central to ecommerce, and Shopify’s standard discount features handle common cases well — percentage off, fixed amount off, buy-X-get-Y, free shipping. But many merchants, especially larger and Plus merchants, need discount logic beyond the standard: tiered discounts (spend more, save more), conditional discounts (based on cart contents, customer segments, product combinations), complex promotional rules, and custom logic the standard discounts can’t express. This is where Shopify Functions come in: Functions let developers build custom discount logic that runs natively in Shopify (including in the checkout), implementing the bespoke, complex, or conditional discounts standard features can’t. Functions are the modern, native way to do custom discount logic on Shopify (replacing the older Scripts, as the Scripts-to-Functions discussion covers), and for merchants with sophisticated promotional needs, they unlock powerful, performant custom discounting. This piece covers custom discount logic with Functions — what it enables, how it works, and when you need it. (This connects to the Shopify-Functions-explained and Scripts-to-Functions discussions; this focuses specifically on custom discount logic.)

This piece covers what Shopify Functions are (briefly) and custom discounts specifically, what custom discount logic enables, how it works and is built, and when you need it. Because custom discount logic via Functions unlocks sophisticated promotions, and understanding it helps you know what’s possible and when to use it. Let me walk through it. (Note: Shopify Functions, including discount functions, are primarily a Shopify Plus capability; verify current availability for your plan.)

Shopify Functions and custom discounts (briefly)

Briefly, what Shopify Functions are and how discounts fit (covered more fully in the Functions-explained discussion). Shopify Functions — Functions let developers write custom backend logic that runs natively within Shopify’s systems (including checkout), customising Shopify’s behavior for various extension points — discounts, shipping, payment customisation, and more — performantly and natively (versus apps or the older Scripts). Discount functions — one key extension point is discounts: discount Functions let developers implement custom discount logic (how discounts are calculated and applied, based on custom rules and conditions), running natively in Shopify including at checkout. Native and performant — because Functions run natively in Shopify (not as external app calls), they’re fast and reliable, suitable for checkout (where the older Scripts ran, now migrating to Functions, as that discussion covers). Replaces Scripts — Functions are the modern replacement for Shopify Scripts (which did similar custom checkout logic, including discounts, and are being deprecated, as the Scripts-to-Functions discussion covers), so custom discount logic that was done in Scripts is now done in Functions. So Shopify Functions let developers build custom native logic at various extension points, including discounts, where discount Functions implement custom discount logic running natively (including at checkout) — the modern, performant, native way to do custom discounts, replacing Scripts. So custom discount logic via Functions is the current way to implement bespoke discounting on Shopify (Plus), and the next sections cover what it enables and how. So understand Functions as the native custom-logic capability, with discounts as a key use.

What custom discount logic enables

Custom discount logic via Functions enables sophisticated discounting beyond standard features. Tiered discounts — spend-more-save-more tiers (e.g., 10% off $100+, 15% off $200+, 20% off $300+), encouraging larger orders (raising AOV, as that discussion covers), which standard discounts don’t do natively. Conditional discounts — discounts conditional on cart contents, combinations, or rules (e.g., discount when specific products are together, discount on the cheapest/most expensive item, discount based on quantity or combination), enabling complex conditional promotions. Customer-segment discounts — discounts based on customer segments (e.g., VIP customers, wholesale/B2B customers as the B2B discussion covers, loyalty tiers), giving different customers different pricing/discounts. Complex promotional rules — complex promotions with custom rules (e.g., “buy 2 of category A and get the cheapest item in category B free,” or intricate bundle/promotion logic) that standard discounts can’t express. Bundle and combination discounts — discounts for buying specific bundles or combinations (as the bundles discussion covers), implemented with custom logic. Exclusions and conditions — custom exclusions and conditions (e.g., discounts that exclude certain products, apply only under conditions), giving precise control. And custom calculation — custom discount calculation logic (how the discount amount is determined), beyond standard percentage/fixed. So custom discount logic enables tiered discounts (spend-more-save-more), conditional discounts (based on cart/combinations/rules), customer-segment discounts (VIP, B2B, loyalty), complex promotional rules, bundle/combination discounts, custom exclusions and conditions, and custom calculation — sophisticated discounting beyond standard features. The common thread is bespoke, conditional, complex discount logic tailored to your promotional strategy, which standard discounts can’t express. So Functions unlock the sophisticated, custom discounting that larger and Plus merchants often need for their promotional strategies. So if your promotional needs exceed standard discounts (tiered, conditional, segmented, complex), custom discount logic via Functions enables them.

How it works and is built

A bit on how custom discount logic via Functions works and is built (at a conceptual level — implementation is developer work). Developers build the Function — a developer writes the discount Function (code, in a supported language, deployed to Shopify), implementing your custom discount logic (the rules, conditions, calculations), which runs natively in Shopify. Runs natively at checkout — the Function runs natively within Shopify’s discount system (including at checkout), evaluating the cart and applying the custom discount per your logic, performantly and reliably (native, not an external call). Configured for your rules — the Function implements your specific discount rules (the tiers, conditions, segments, combinations, calculations you need), so it applies discounts according to your promotional strategy. Integrates with Shopify’s discounts — Functions integrate with Shopify’s discount and checkout systems, so the custom discounts work within Shopify’s flow (applied to the cart, shown to the customer, processed at checkout). Tested and reliable — like any checkout-affecting logic, discount Functions must be built carefully and tested thoroughly (the checkout and discounts are business-critical — errors affect pricing and purchases, as the cart and checkout discussions cover). Developer/Plus territory — building discount Functions is developer work (writing and deploying the Function), primarily on Plus (where Functions for discounts are available), so you need development capability (your own or an agency/developer). And maintained — like custom code, Functions are maintained (updated as needs change, as Shopify evolves). So custom discount logic via Functions works by a developer building a discount Function (code implementing your rules) that runs natively in Shopify’s discount system (including at checkout), applying your custom discounts performantly and reliably, integrated with Shopify’s flow, built and tested carefully (business-critical), on Plus, with development capability. So implementation is developer work (building the Function to your rules), but conceptually it’s custom discount logic running natively in Shopify per your promotional strategy. So to use custom discount logic, you’ll work with a developer (or agency) to build the discount Function implementing your needs — getting sophisticated, native, performant custom discounting.

When you need custom discount logic

When do you need custom discount logic via Functions? When standard discounts can’t do it — the clearest sign: your promotional needs exceed what standard Shopify discounts can express (tiered, conditional, segmented, complex promotions standard features don’t support), so custom logic is needed to implement your promotional strategy. For sophisticated promotional strategies — if your promotional strategy relies on sophisticated discounting (tiered incentives, conditional offers, segment-based pricing, complex bundles/promotions), custom discount logic enables it (where standard discounts would limit you). For B2B/wholesale pricing — B2B and wholesale often need custom pricing/discount logic (segment-based pricing, quantity discounts, custom rules, as the B2B and wholesale discussions cover), which Functions can implement. Migrating from Scripts — if you used Shopify Scripts for custom checkout discount logic, you need to migrate to Functions (Scripts are deprecated, as that discussion covers), so Functions are how you continue custom discount logic. When the value justifies it — building custom discount logic is development work (cost, maintenance), so it’s warranted when the promotional value (the sophisticated discounts driving sales/AOV/strategy) justifies the development. And you’re on Plus with capability — Functions for discounts are primarily Plus, and building them needs development capability, so you need to be on Plus (or the relevant plan) with development resources. Conversely, you don’t need it when — standard Shopify discounts meet your promotional needs (many stores’ discounting is well-served by standard features), in which case custom logic is unnecessary. So you need custom discount logic when standard discounts can’t express your promotional needs (tiered, conditional, segmented, complex), your strategy relies on sophisticated discounting, you’re doing B2B/wholesale with custom pricing needs, you’re migrating from Scripts, the promotional value justifies the development, and you’re on Plus with capability — while you don’t need it if standard discounts suffice. So assess whether your promotional needs exceed standard discounts (and the value justifies custom development) — if so, custom discount logic via Functions is the way; if not, standard discounts suffice. So custom discount logic is for the merchants (often larger/Plus) whose promotional strategies need sophisticated, custom discounting beyond the standard.

A worked example: a tiered-plus-segment promotion

Picture a Plus merchant who sells both DTC and wholesale and wants a promotion standard discounts simply can’t express. For DTC customers, they want a tiered “spend more, save more” structure — 10% off orders over $75, 15% over $150, 20% over $250 — to push average order value up. For wholesale customers, they want different logic entirely: segment-based pricing where verified B2B accounts get their contracted rate plus an extra quantity break (an additional discount when they order above a case quantity). And they want to exclude a handful of already-discounted clearance products from all of it, and make sure the DTC tiered discount and a separate free-shipping threshold play together sensibly.

None of that is expressible in standard Shopify discounts — the tiers, the customer-segment logic, the quantity breaks, the exclusions, and the interaction rules are exactly the kind of bespoke, conditional, layered logic that custom discount Functions exist for. So a developer builds a discount Function that, at checkout, evaluates the cart: it checks whether the customer is a DTC or verified wholesale account, applies the appropriate logic (the spend tiers for DTC, the contracted rate plus quantity break for wholesale), excludes the clearance items from the calculation, and coordinates with the free-shipping rule — all running natively so it’s fast and reliable enough for checkout. Because pricing is business-critical, the Function is tested hard across the scenarios (each DTC tier boundary, wholesale accounts at and above the quantity break, carts containing excluded clearance items, edge cases where rules could conflict) before going live. The result is a single promotional system that does sophisticated, segment-aware, tiered, conditional discounting that standard features couldn’t touch — exactly the kind of capability that justifies being on Plus and investing in custom logic. The lesson is that custom discount Functions shine precisely when your promotional strategy is layered and conditional like this; for a store whose discounting is “10% off site-wide,” standard discounts are entirely sufficient and Functions would be overkill.

Functions, Scripts, and the bigger discounting picture

It’s worth placing custom discount Functions in the broader context of how discounting on Shopify has evolved and how it fits with the rest of your promotional toolkit. Historically, merchants who needed custom checkout discount logic used Shopify Scripts; Scripts are being deprecated in favour of Functions (as the Scripts-to-Functions discussion covers), so Functions are now both the modern way to build new custom discount logic and the destination for migrating existing Script-based logic. If you have legacy Scripts doing custom discounts, planning that migration to Functions is part of keeping your discounting working as Shopify evolves — not an optional nicety but a necessary modernisation.

It’s also worth remembering that custom discount logic is one tool among several, and the right approach often combines them. Standard Shopify discounts handle the common cases and should be used where they suffice (no need to build a Function for “10% off”). Automatic discounts and discount codes cover a lot of everyday promotional needs. Gift-with-purchase logic (as that discussion covers) overlaps with custom discount territory and can sometimes be implemented via Functions too. And for B2B, native B2B pricing features plus custom discount logic together cover sophisticated wholesale pricing (as the B2B and wholesale discussions cover). So think of custom discount Functions as the powerful option you reach for when standard tools can’t express what your strategy needs — tiered, conditional, segmented, complex logic — rather than the default for all discounting. Used that way, in concert with standard discounts where they suffice and as the modern home for what used to live in Scripts, Functions give Plus merchants a complete, performant, native discounting capability that scales from the simple to the sophisticated. The skill is matching the tool to the need: standard discounts for the common, Functions for the bespoke, and a clear migration plan for any legacy Scripts still in play.

The bottom line

Discounts and promotions are central to ecommerce, and Shopify’s standard discount features handle common cases well (percentage off, fixed amount, buy-X-get-Y, free shipping) — but many merchants, especially larger and Plus merchants, need discount logic beyond the standard: tiered discounts (spend-more-save-more), conditional discounts (based on cart contents, combinations, or rules), customer-segment discounts (VIP, B2B, loyalty), complex promotional rules, bundle/combination discounts, custom exclusions, and custom calculations. Shopify Functions are the modern, native way to build this custom discount logic — discount Functions let developers implement bespoke discount logic that runs natively within Shopify’s discount system (including at checkout), performantly and reliably, replacing the older, now-deprecated Scripts (as the Scripts-to-Functions discussion covers). Custom discount logic via Functions unlocks the sophisticated, conditional, complex discounting tailored to your promotional strategy that standard discounts can’t express. Conceptually, a developer builds the discount Function (code implementing your specific rules, conditions, and calculations) that runs natively in Shopify, applying your custom discounts integrated with Shopify’s checkout flow — built and tested carefully (the checkout and discounts are business-critical, so errors affect pricing and purchases), on Plus (where discount Functions are primarily available), with development capability (your own or an agency). You need custom discount logic when standard discounts can’t express your promotional needs (tiered, conditional, segmented, complex), your strategy relies on sophisticated discounting, you’re doing B2B/wholesale with custom pricing needs, you’re migrating from Scripts, the promotional value justifies the development, and you’re on Plus with capability — while you don’t need it if standard Shopify discounts meet your needs (as they do for many stores). So assess whether your promotional needs exceed standard discounts and whether the value justifies custom development: if so, custom discount logic via Functions gives you sophisticated, native, performant custom discounting (built with a developer); if not, standard discounts suffice. For merchants whose promotional strategies need it, Functions unlock powerful custom discounting that standard features can’t match — a key capability for sophisticated, especially Plus, promotional needs.

Frequently asked questions

What are Shopify Functions used for in discounts?

Shopify Functions let developers build custom discount logic that runs natively within Shopify’s discount system, including at checkout — implementing bespoke, conditional, or complex discounts that Shopify’s standard discount features can’t express. Standard discounts handle common cases (percentage off, fixed amount, buy-X-get-Y, free shipping), but discount Functions enable sophisticated logic: tiered discounts (spend more, save more), conditional discounts (based on cart contents, product combinations, or custom rules), customer-segment discounts (VIP, B2B, loyalty tiers), complex promotional rules, bundle and combination discounts, custom exclusions, and custom calculations. Functions run natively (not as external app calls), so they’re fast and reliable enough for checkout, and they’re the modern replacement for the older, now-deprecated Shopify Scripts. They’re primarily a Shopify Plus capability.

What kind of discounts can I build with Functions that I can’t with standard discounts?

Sophisticated, conditional, and complex discounts that standard features don’t support: tiered “spend more, save more” discounts (10% off $100+, 15% off $200+, and so on, which encourage larger orders), discounts conditional on cart contents or combinations (a discount when specific products are bought together, or on the cheapest or most expensive item), customer-segment-based discounts (different pricing or discounts for VIP, wholesale/B2B, or loyalty-tier customers), complex promotional rules (intricate “buy this and get that” logic), bundle and combination discounts, and custom exclusions and conditions. Essentially, anywhere your promotional strategy needs bespoke, conditional, or complex discount logic tailored to specific rules — which standard percentage, fixed-amount, and buy-X-get-Y discounts can’t express — custom discount Functions can implement it.

Do I need to be on Shopify Plus to use custom discount Functions?

Shopify Functions for discounts are primarily a Shopify Plus capability, so custom discount logic via Functions is generally a Plus feature (you should verify current availability for your specific plan, as Shopify’s capabilities evolve). Building discount Functions also requires development capability — a developer writes and deploys the Function implementing your custom discount logic — so you need development resources (your own team or an agency/developer). This makes custom discount logic via Functions most relevant to larger and Plus merchants who both have sophisticated promotional needs that exceed standard discounts and have (or can engage) the development capability to build the Functions. If you’re on standard Shopify and your discounting needs are met by standard features, you don’t need this — it’s for the merchants whose promotional strategies require custom, complex discounting.

How is custom discount logic built and is it safe for checkout?

A developer writes the discount Function (code in a supported language, deployed to Shopify) implementing your specific discount rules, conditions, and calculations, and it runs natively within Shopify’s discount and checkout systems — evaluating the cart and applying your custom discounts as part of Shopify’s flow. Because Functions run natively (not as external app calls), they’re fast and reliable, which is exactly why they’re suitable for checkout (and why they replaced the older Scripts). That said, discounts and checkout are business-critical — errors would affect pricing and purchases — so discount Functions must be built carefully and tested thoroughly before going live, and maintained over time as your needs and Shopify evolve. Implementation is developer work, so you’d engage a developer or agency with Shopify Functions experience to build, test, and maintain the custom discount logic reliably.

Ready to build a Shopify store that converts?

Book a free consultation or request a free Shopify audit. We will review your store and share specific, prioritized opportunities — no obligation.

Free Consultation Free Audit