If you give automatic discounts at checkout with a Shopify Script, that code stops running when Scripts retires on June 30, 2026. The good news: discounts are the most straightforward thing to move to Shopify Functions, and the new version is faster and works on more plans.
This is the focused version for discounts. For the full picture across discounts, shipping, and payments, read the Scripts to Functions migration guide.
What you have today
A line item Script in the Script Editor that reads the cart and applies a discount. Common patterns:
- A tiered discount based on cart total (spend more, save more).
- A reward for returning customers based on their order count.
- An automatic discount by cart value.
- A free gift during a promotion.
All of these are the same shape: look at the cart and customer, decide a discount, return it.
What it becomes
A discount function, an app extension you build with the Shopify CLI in JavaScript or Rust. It declares the cart and customer fields it needs in a GraphQL input query, runs a run function, and returns discount operations. You attach it to an automatic discount (or a discount code) in the admin, and it fires at checkout.
The logic maps almost one to one. A Script that did this:
# Old: line item Script
if Input.cart.subtotal_price >= Money.new(cents: 10000)
Input.cart.line_items.each do |item|
item.change_line_price(item.line_price * 0.9, message: "10% off orders over $100")
end
end
becomes a function whose run reads the cart subtotal from its input and returns a 10% order discount with the same message. The decision (subtotal at or above $100) is identical, you are just returning an operation instead of mutating the cart in place.
The migration in five steps
- Create a custom app if you do not already have one. Functions ship as extensions of an app.
- Generate a discount function with the Shopify CLI and choose the discount API.
- Request only the inputs you need (cart cost, customer, line item attributes) in the function's input query, this is what keeps it fast.
- Port your rule into
run. Return a product discount or order discount with the same threshold and message your Script used. - Deploy, then create an automatic discount in the admin that points at the function. Test in a real checkout, then delete the old Script.
Watch for these
- A discount function does nothing until an automatic discount (or code) in the admin is attached to it. The function alone is not enough.
- Free gifts usually combine a discount function (to make the gift free) with how the item gets added to the cart, plan that flow, do not assume the Script's
change_line_pricetrick carries over unchanged. - Re-test logged-out customers and mixed carts. Inputs that are not in your query are invisible to the function.
Need it done before the deadline
We migrate discount Scripts to Functions every week. Send us your Script Editor list and we will rebuild each one, tested and live, well before June 30, 2026.

