1. Home
  2. Guides
  3. Custom discounts with Shopify Functions

Custom Shopify Discounts: Tiered Pricing, Free Gifts and Bundles

By Thanh “Nathan” Bui Tuan 8 min read

Shopify's built-in discounts handle the basics well: a percentage off, a fixed amount, free shipping, buy X get Y. But many promotions merchants want sit just beyond them: tiered pricing that rewards bigger baskets, a free gift that appears at a spend threshold, a bundle priced as a set, or special pricing for wholesale customers.

That's where Shopify Functions come in. This guide explains what they are, which offers they make possible, and how to decide between an app and custom code.

Key takeaways

  • Built-in discounts cover standard promotions. Functions cover custom rules.
  • Functions run on Shopify's side, so the discount is applied consistently in the cart and at checkout.
  • Many offers have two parts: the discount logic, and what the customer sees on the store.

What the built-in discounts do well

Shopify's discount codes and automatic discounts let you take a percentage or fixed amount off products or orders, run buy X get Y offers and offer free shipping, with options for minimum purchase, customer eligibility and dates. If your promotion fits in those boxes, use them. They're free, maintained by Shopify and easy for your team to manage.

Where merchants hit the limits

  • Tiered quantity pricing, such as "buy 2 save 10%, buy 3 save 15%, buy 5 save 20%", across a set of products.
  • A free gift at a spend or quantity threshold, especially one that is added automatically.
  • Bundle pricing: products A, B and C together for a set price or percentage off.
  • Customer-specific rules, such as wholesale or VIP pricing based on tags or segments.
  • Complex stacking rules, where you need to control exactly which discounts can combine.
  • Delivery rules that depend on what is in the cart.

What are Shopify Functions?

Shopify Functions let developers customize backend logic that Shopify runs for you at key moments: calculating discounts, shaping delivery options, customizing payment methods and validating the cart. A Function is delivered inside an app. You install the app, and your team configures it in the Shopify admin.

Because Functions run on Shopify's infrastructure, not in the visitor's browser, the result is applied consistently in the cart and at checkout, and it can't be bypassed by changing the page's code. They run in a tightly limited environment, which keeps them fast and predictable while a customer is checking out.

Offers you can build

Buy More, Save More (tiered discounts)

The discount grows with quantity or order value. Set tiers per product, per collection or for the whole cart, and show them on the product page so customers see the incentive before they add to cart.

Free gift with purchase

This usually has two parts. The Function applies a 100% discount to the gift item when the rule is met. The storefront, usually the cart page or cart drawer, adds or offers the gift. A cart app or custom cart code can handle that second part.

Bundles

Fixed-price or percentage-off bundles of selected products, including "build your own" selections where the customer picks the items.

B2B and customer-based pricing

Pricing by customer tag, segment or company. For wholesale, check Shopify's built-in B2B features first, since catalogs and price lists may cover your case without any custom code.

Shipping rules

Free shipping above a threshold for certain products, or hiding and renaming delivery options depending on what's in the cart.

App or custom code?

If your promotion is common, an existing app is the quickest route. I've built a couple of these myself: Ultimate Discount Manager, built on Shopify Functions for bundles, tiered discounts, free gifts, free shipping and B2B pricing, and Discounts Combine, for combined and automatic discounts.

If your rules are unusual, such as unique tier logic or data that lives outside Shopify, or if you'd rather not pay a monthly fee, a custom Function inside a private app is built around your exact rules.

Existing appCustom Function
Speed to launch Fast: install and configure Slower: it has to be designed and built
Cost Usually a monthly subscription, which may grow with your store An upfront development cost, with no recurring app fee for the discount logic itself
Flexibility Limited to what the app supports Built around your rules
Maintenance Handled by the app developer Yours, or your developer's, as Shopify evolves

For a wider look at budgeting, see what drives the cost of Shopify development.

Plan your promotion before you build

Write the rules down as a short sheet. A clear one answers:

  • Who qualifies, and are some customers excluded?
  • Which products or collections are included or excluded?
  • What triggers the offer: quantity, spend or something else?
  • What is the reward?
  • Can it stack with codes and other automatic discounts?
  • Does it apply to items that are already on sale?
  • When does it start and end?

Then think through the edge cases: returns and refunds, multiple currencies and rounding, subscriptions, and gift cards. Test every scenario on a development store or with test orders before the promotion goes live.

Common mistakes

  • Accidental stacking, which gives away more margin than planned.
  • Hiding the offer. If customers don't see it on the product page and in the cart, they won't act on it.
  • Forgetting mobile, where most of your shoppers may be.
  • Testing only the simple case and not combinations with discount codes and shipping.
  • Hard-coding values your marketing team should be able to change themselves.

Once a promotion is live, keep it healthy with regular checks. See what ongoing maintenance covers.

Need a custom discount or promotion?

Custom cart, discount and promotion logic is one of the things I build most, from tiered offers and free gifts to B2B pricing. Describe the promotion you have in mind and I'll tell you whether an existing app can do it or whether custom code makes sense.

Contact me directly for a better rate

Have a Shopify project in mind?

Tell me what you're building or what needs fixing. Message me directly for a better rate than my Upwork listing, and I'll get back to you with questions and a plan.

Prefer Upwork? Check my Upwork profile