The Functions Console gets a fourth category:
Discounts
. Write JavaScript that applies automatic discounts at checkout — any rule you can express in code, from "10% off tagged products" to "amount off orders over a threshold for returning customers".- 🏷️ Product discounts— percentage or fixed amount off individual cart lines, targeted by product, tags, collections or anything else in the input.
- 🧾 Order discounts— discount the order subtotal based on cart totals, customer, address, time of day and more.
How it works
Open the
Discounts
folder in the Functions Console and click Add new
. Pick a family — the same 13 families you know from validations and customizations decide which checkout data your code sees — and write a function body that returns discount operations. The starter code documents the exact shapes, and the editor's autocomplete knows your input inside out.Turn the function on and the discount is live at checkout immediately. It also shows up on the Shopify admin
Discounts
page like any other automatic discount, and it combines with your existing discounts.A few things worth knowing
- The function's title is shown to buyersat checkout as the discount name — pick something shelf-ready likeLoyalty 10% off.
- New discount functions are created turned offso you can review the code first. Active discounts count toward your plan's active-function limit, and Shopify allows up to 25 active automatic discounts per store.
- Like all functions, discounts are free— they don't consume credits.
- Discounts fail open: if your code errors, checkout continues with no discount applied — buyers are never blocked.
- Query and code variables work exactly like in the other categories, so merchants can tweak thresholds and percentages from the dashboard without touching code.
- The AI assistantcan build discount functions for you — describe the rule in Build with AI and review what it writes.
Full guide and ready-made examples in the docs:
Functions → Discounts
.