Shopify Functions Explained: Custom Discounts, Shipping and Payment Rules, With Examples
Shopify Functions explained: what they customise, who can use them, real examples and tips for building discount, shipping and payment rules.
Shopify Functions let developers extend or replace Shopify’s server-side business logic, such as how discounts are calculated or which shipping options appear. They replaced Shopify Scripts, which stopped running on June 30, 2026. Here is what they do and when to use them.
What a Function is
A Function is a small piece of code that runs on Shopify’s infrastructure at a specific point, such as when the cart is calculated. It receives data about the cart, runs your logic and returns instructions. Because it runs on Shopify’s side, it is built to be fast and safe at scale.
What you can customise
Function APIs cover areas such as:
- Discounts on products, orders and shipping
- Delivery customisation, such as renaming, hiding or reordering shipping options
- Payment customisation, such as hiding or reordering payment methods
- Cart and checkout validation, such as blocking an order that breaks a rule
- Cart transformation, such as bundling or expanding items
- Order routing, such as choosing which location fulfils an order
Check Shopify’s developer documentation for the current list of APIs, since new ones are added regularly.
Examples
Tiered B2B pricing. Give a customer group lower prices as quantity increases. From API version 2026-04, Functions can read metaobject entries, which is useful for structured data such as tier tables.
Hide a payment method. Hide cash on delivery for orders over a certain value.
Rename shipping options. Show “Free delivery in 3 to 5 days” instead of a carrier code.
Stackable promotions. Combine a product discount with a shipping discount. Shopify’s Winter ’25 Edition raised the number of discount Functions that can run on a store to 25, up from 5.
Block unsupported orders. Stop checkout if a basket mixes items that cannot ship together.
Who can use them
Public apps in the Shopify App Store can use Functions on any plan, so many merchants benefit without writing code. Custom apps containing Function APIs have been limited to Shopify Plus stores, according to Shopify’s developer changelog, so check current rules for your plan.
Winter ’25 also made Functions apply to draft orders, so staff-created orders follow the same rules as online checkout.
How they differ from Scripts
- They run as compiled code, not Ruby scripts.
- They are delivered through apps, which makes them easier to version and share.
- They work with checkout extensibility instead of the old checkout.
Tips for building
- Define the rule in plain English before coding.
- Keep Functions small and focused.
- Test with real cart data and edge cases.
- Handle empty or unexpected inputs safely.
- Watch performance limits in Shopify’s documentation.
- Version and document your logic.
FAQ
Do I need to code? Not always. Many apps provide Function-based features through settings screens.
Can I use Functions on a basic plan? Through public apps, yes. Custom Function apps have been limited to Plus.
Related reading: Shopify Checkout Editor for Plus: A Drag-and-Drop Checkout Guide, Theme App Extensions vs. Script Tags and 12 Shopify Flow Automations Every Store Should Set Up.
Need a custom Function?
Liquid Gold builds custom apps and Functions for discounts, shipping and checkout rules. Talk about a custom app →