Vai al contenuto
Esempi di Script

Migrating a spend threshold amount off script

Two Money.new calls sit in this file and nothing about their syntax says which is the threshold and which is the reward. Whichever a naive reader takes first wins, and the two answers are $100 off and $15 off.

Ricostruito
Cosa faceva lo Script

It took a fixed sum off the order once the cart subtotal reached a threshold.

Provalo sul tuo negozio

Incollalo in Recupero Script e guarda cosa ricostruisce

  1. Copia il Ruby con il pulsante accanto a ogni Script di questa pagina.
  2. Nell'admin di Shopify apri Stackable, poi Strumenti, poi Recupero Script.
  3. Incollalo lì, leggi cosa dichiara di costruire lo strumento e confrontalo con le impostazioni di questa pagina.

Recupero Script è nel piano Pro. Non viene pubblicato nulla finché non dichiari quanto scontava il vecchio Script e le due cifre non coincidono al centesimo.

Lo Script

Ricostruito

Coppia rischiosa D2. Questo file e il suo gemello sembrano quasi identici e si comportano in modo diverso, quindi leggili entrambi prima di decidere quale hai.

Il Ruby originale

THRESHOLD = Money.new(cents: 10000)
REWARD = Money.new(cents: 1500)

if Input.cart.subtotal_price >= THRESHOLD
  remaining = REWARD
  Input.cart.line_items.each do |line_item|
    break if remaining <= Money.zero
    share = [line_item.line_price, remaining].min
    line_item.change_line_price(line_item.line_price - share, message: "Spend $100, get $15 off")
    remaining = remaining - share
  end
end

Output.cart = Input.cart
In cosa si trasforma

Riconosciuto come Amount off the order e ricostruito come offerta di tipo spend_goal. Queste sono le vere chiavi di configurazione con cui l'offerta viene salvata, così puoi confrontare la tua ricostruzione campo per campo.

Ogni impostazione, nel dettaglio
ImpostazioneValoreChiave di configurazione
Offer typespend_goaltype
Countingper_cartcounting
Recurrenceoncerecurrence
Tier 1min spend $100.00 -> $15.00 off eachtiers[0]
Target scopealltarget.scope
MethodautomaticdiscountMethod
Allocationstandardstacking.allocation
Combines with other discountsnostacking
Ti verrà chiesta una conferma
  • Confirm which products this applies to. We could not read product targeting from the script.
Ti verrà comunicato
  • A fixed amount off the order is spread across the items at checkout, so each line shows part of it rather than one line carrying the whole discount.
Il carrello che lo dimostra

Creato sul nostro negozio demo pubblico, Meridian Goods, così ogni prezzo qui si può riprodurre invece di doverci credere sulla parola. Lo sconto qui sotto è quello che lo stesso motore che gira al checkout calcola per questo esatto carrello.

Il carrello che attiva questa offerta, e quanto costa
ArticoloQtàPrezzo unit.
Felt Laptop Sleeve2$38.00
Impact Phone Case1$24.00
Subtotale$100.00
Sconto-$15.00
Totale$85.00

Nessun accesso, oppure accesso come cliente senza tag.

La cifra con cui lo strumento ti confronta

Prima della pubblicazione, lo strumento chiede cosa faceva il tuo vecchio Script a un carrello che hai già. Impostalo su 4 di Walnut Desk Organizer a $26.00 e la risposta è fissata.

Lo sconto è $15.00. Il totale pagato dal cliente è $89.00.

Il confronto è esatto, fino alla più piccola unità della tua valuta. Un centesimo di scarto e la pubblicazione resta bloccata, che è tutto il senso di questo passaggio.

Il carrello che non deve produrre nulla
  • drop to 1 of the same product, under what the rule needs
Il carrello che non deve attivare questa offerta
ArticoloQtàPrezzo unit.
Felt Laptop Sleeve1$38.00
Subtotale$38.00
Totale$38.00

Nessun accesso, oppure accesso come cliente senza tag.

Due file che sembrano uguali

Ogni coppia qui sotto è la stessa forma di Script scritta in due modi. Cambiano una o due righe e fanno cose diverse, quindi leggile entrambe prima di decidere quale hai.

Coppia insidiosa D2

Spend threshold fixed amount (D2)

Ricostruito

Ricostruito come offerta spend_goal.

Sconto sul suo carrello: $15.00

Righe che cambiano
REWARD = Money.new(cents: 1500)
  remaining = REWARD
    break if remaining <= Money.zero
    share = [line_item.line_price, remaining].min
    line_item.change_line_price(line_item.line_price - share, message: "Spend $100, get $15 off")
    remaining = remaining - share
Leggi Spend threshold, amount off

Spend threshold percentage (D2)

Ricostruito

Ricostruito come offerta spend_goal.

Sconto sul suo carrello: $15.00

Righe che cambiano
    line_item.change_line_price(line_item.line_price * (1.0 - (15 / 100.0)), message: "Spend $100, save 15%")
Leggi Spend threshold, percentage

Domande frequenti

Will Stackable rebuild this script?
Yes. Every spelling on this page is rebuilt today as a spend_goal offer, and the cart above is the one that proves it.
What cart proves it works?
2 x Felt Laptop Sleeve at $38.00 plus 1 x Impact Phone Case at $24.00. The engine takes $15.00 off, and checkout charges $85.00.
What will I have to check before publishing?
Confirm which products this applies to. We could not read product targeting from the script. A fixed amount off the order is spread across the items at checkout, so each line shows part of it rather than one line carrying the whole discount.

Forme di Script correlate

Spend threshold, percentage

A percentage that unlocks once the cart is worth enough.

Discounted cart subtotal

A threshold read from what was left after a code had already come off.

Incolla il tuo Script e guardalo ricostruito

La ricostruzione viene confrontata con l'importo che il tuo vecchio Script applicava, prima che tu possa pubblicarla.

Utilizziamo cookie essenziali per il funzionamento del sito e, solo con il Suo consenso, cookie di analisi per comprendere il traffico. Legga la nostra Informativa sui Cookie.