Skip to content
Scripts examples

Migrating a first order discount script

This appears in Shopify’s own repo, in the Help Center library and in the generator, which is more independent official appearances than almost any other script shape. Note that most versions treat a logged-out shopper as a first-time buyer.

Not supported yet
What the Script did

It compared the customer’s past order count to a number before applying anything.

Run it against your own store

Paste it into Scripts rescue and watch what it rebuilds

  1. Copy the Ruby with the button beside any Script on this page.
  2. In your Shopify admin, open Stackable, then Tools, then Scripts rescue.
  3. Paste it there, read what the tool says it will build, and compare that with the settings on this page.

Scripts rescue is on the Pro plan. Nothing is published until you tell it what your old Script charged and the two figures match to the cent.

The Script

Not supported yet
The original Ruby

DISCOUNT_PERCENTAGE = 20

if Input.cart.customer.nil? || Input.cart.customer.orders_count < 1
  Input.cart.line_items.each do |line_item|
    line_item.change_line_price(
      line_item.line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0)),
      message: "20% off your first order"
    )
  end
end

Output.cart = Input.cart
What happens to this one

We have not built this yet

Your Script checked how many orders the customer had placed. Shopify can tell us, but our checkout query is already at Shopify's cost limit, so we cannot ask for it today.

This is our gap, not Shopify's. Shopify permits it and we have not built it, so there is nothing here to link to and nothing to blame the platform for.

Reason key: unsupported.customerOrderCount

There is no cart to test here, because nothing is built. Pasting this produces the message above and no campaign at all.

Common questions

Will Stackable rebuild this script?
No, and the reason is stated rather than hidden: Your Script checked how many orders the customer had placed. Shopify can tell us, but our checkout query is already at Shopify's cost limit, so we cannot ask for it today.

Related Script shapes

First time customer, cheapest item

A new-customer gate wrapped around a cheapest-item reward.

Lifetime spend discount

A reward for customers who had spent enough over their lifetime.

Customer tag discount

A discount only tagged customers ever saw.

Paste your Script and see it rebuilt

The rebuild is checked against the money your old Script charged before you can publish it.

We use essential cookies to run this site, and, only with your permission, analytics cookies to understand traffic. Read our Cookie Policy.