Hoppa till innehåll
Script-exempel

Migrating the 20 percent off first time customers script

The clearest illustration of why a migration tool has to refuse a partial answer. The reward half is perfectly readable and the condition half is not, and rebuilding the reward alone would hand every shopper a permanent discount.

Stöds inte än
Vad detta Script gjorde

It gave a percentage off the cheapest item, but only to shoppers who had never ordered before.

Testa det i din egen butik

Klistra in det i Scripts-räddning och se vad som byggs

  1. Kopiera Ruby-koden med knappen bredvid vilket Script som helst på sidan.
  2. Öppna Stackable i Shopify-adminen, sedan Verktyg, sedan Scripts-räddning.
  3. Klistra in det där, läs vad verktyget säger att det ska bygga och jämför med inställningarna på den här sidan.

Scripts-räddning ingår i Pro-planen. Ingenting publiceras förrän du anger vad ditt gamla Script gav i rabatt och båda beloppen stämmer på öret.

Detta Script

Stöds inte än
Den ursprungliga Ruby-koden

DISCOUNT_AMOUNT = 20

if Input.cart.line_items.size > 1 && (Input.cart.customer.nil? || Input.cart.customer.orders_count < 1)
  line_item = Input.cart.line_items.sort_by { |li| li.variant.price }.first
  if line_item.quantity > 1
    line_item = line_item.split(take: 1)
    Input.cart.line_items << line_item
  end
  line_item.change_line_price(
    line_item.line_price * (1.0 - (DISCOUNT_AMOUNT / 100.0)),
    message: "20% off for first time customers"
  )
end

Output.cart = Input.cart
Vad som händer med den här

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.

Det här är vår lucka, inte Shopifys. Shopify tillåter det och vi har inte byggt det, så det finns inget att länka till här och inget att skylla på plattformen.

Orsaksnyckel: unsupported.customerOrderCount

Det finns ingen varukorg att testa här, eftersom ingenting byggs. Att klistra in det här ger meddelandet ovan och ingen kampanj alls.

Vanliga frågor

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.

Besläktade Script-former

First order discount

A discount for shoppers with no order history, or with enough of it.

Lifetime spend discount

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

Customer tag discount

A discount only tagged customers ever saw.

Klistra in ditt Script och se det byggas om

Ombyggnaden stäms av mot beloppet som ditt gamla Script tog ut innan du kan publicera den.

Vi använder nödvändiga cookies för att driva den här webbplatsen, och, bara med ditt tillstånd, analyscookies för att förstå trafiken. Läs vår Cookiepolicy.