Migrating a discount code driven script
The script did not own the code; a native Shopify discount did, and the script watched for it. A rebuilt offer owns its code outright, which is the same shopper experience through a different mechanism.
RicostruitoIt inspected the discount code the shopper had entered and branched on it.
Incollalo in Recupero Script e guarda cosa ricostruisce
- Copia il Ruby con il pulsante accanto a ogni Script di questa pagina.
- Nell'admin di Shopify apri Stackable, poi Strumenti, poi Recupero Script.
- 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
RicostruitoBONUS_PERCENTAGE = 10
code = Input.cart.discount_code
unless code.nil?
case code
when CartDiscount::Percentage
if code.code == "VIP20"
Input.cart.line_items.each do |line_item|
line_item.change_line_price(
line_item.line_price * (1.0 - (BONUS_PERCENTAGE / 100.0)),
message: "Extra 10% with VIP20"
)
end
end
end
end
Output.cart = Input.cartRiconosciuto come Percentage off e ricostruito come offerta di tipo volume. Queste sono le vere chiavi di configurazione con cui l'offerta viene salvata, così puoi confrontare la tua ricostruzione campo per campo.
| Impostazione | Valore | Chiave di configurazione |
|---|---|---|
| Offer type | volume | type |
| Counting | per_product | counting |
| Recurrence | once | recurrence |
| Tier 1 | min qty 1 -> 10% off | tiers[0] |
| Target scope | all | target.scope |
| Method | code | discountMethod |
| Allocation | standard | stacking.allocation |
| Combines with other discounts | no | stacking |
- Confirm which products this applies to. We could not read product targeting from the script.
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.
| Articolo | Qtà | Prezzo unit. |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| Subtotale | $14.00 | |
| Sconto | -$1.40 | |
| Totale | $12.60 | |
Nessun accesso, oppure accesso come cliente senza tag.
Prima della pubblicazione, lo strumento chiede cosa faceva il tuo vecchio Script a un carrello che hai già. Impostalo su 1 di Braided USB-C Cable a $14.00 e la risposta è fissata.
Lo sconto è $1.40. Il totale pagato dal cliente è $12.60.
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.
This rule carries no condition at all, so it fires on any cart holding anything and there is no quiet cart to build. The negative check is an empty cart, which the app runs for you. That is correct behaviour, not a failure.
Domande frequenti
- Will Stackable rebuild this script?
- Yes. Every spelling on this page is rebuilt today as a volume offer, and the cart above is the one that proves it.
- What cart proves it works?
- 1 x Braided USB-C Cable at $14.00. The engine takes $1.40 off, and checkout charges $12.60.
- What will I have to check before publishing?
- Confirm which products this applies to. We could not read product targeting from the script.
Forme di Script correlate
A code the shopper typed, turned away at checkout with a message.
A whole family of codes driving one rule through a prefix match.
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.