Platform and build
5 min read
Shopify discounts with Functions: what a custom rule can do
Shopify Functions let a developer write a discount rule that the standard discount options cannot handle. Shopify's documentation describes discount classes for orders, products and shipping, and says Shopify runs the function in real time as buyers add products to their cart. Custom rules suit specific offers, not every promotion.

What standard discounts cannot do
Shopify’s standard discount options cover many common offers. Some offers need a rule they do not cover, such as a discount that depends on a product tag and a shipping rate at the same time, or a volume rule that a merchant wants to control in one place. Shopify’s documentation describes Functions as the way to create discount functionality that is not offered out of the box.
How Functions fit in
A Function is custom logic that runs as part of the discount calculation. Shopify’s documentation says it calculates discounts in real time when buyers add products to the cart. That timing matters: the rule has to be fast, predictable and tested with real cart combinations.
The three discount classes
Shopify’s discount documentation uses three classes: Order, Product and Shipping. An Order discount can apply to the order subtotal. A Product discount applies to cart lines. A Shipping discount applies to shipping rates. The documentation gives examples such as reducing the price of a product and a shipping rate at once, and volume discounts.
Choose the class that matches the offer. A shipping offer should not be built as a product discount, because the logic and the testing will be harder to follow.
What to test before launch
Test every combination that a customer can reach. Add products in different quantities, mix the offer with other discounts, and check the totals on the cart and on the checkout page. Check rounding on the smallest and largest orders. Test on a phone, and check what the customer sees if the offer no longer applies.
When not to build one
If a standard discount does the job, use it. Custom logic adds a maintenance cost, and it needs retesting when the store changes. Build one when the rule is specific, has a clear owner and will run for long enough to justify the work.
If you have an offer that the standard options cannot express, describe the rule in plain words. That is the first step in deciding whether a custom build is worth it.
Questions, answered.
Do I need Shopify Plus to use Functions?
Can a Function replace an app?
Who builds a Function?
Category
Platform and build
Read time
5 min read
Published
(More)
Keep Reading
More from the Flight Log.

Buying an agency
How to shortlist a Shopify agency for a food brand
How to shortlist a Shopify agency for a food brand: subscriptions, shipping, labelling and checkout, and the questions that separate a real fit from a sales deck.
Dec 14, 2026

Buying an agency
How much does a Shopify Plus migration cost in the UK?
We do not publish a price range. Here are the cost drivers behind a Shopify migration, and how paid discovery turns them into a fixed quote.
Dec 7, 2026

Buying an agency
What a Shopify discovery session covers
What happens in a paid Shopify discovery session, what you leave with, and why it ends in a fixed quote rather than a guess.

