Vai al contenuto
Esempi di Script

Migrating an exclude gift cards script

This line rarely arrives on its own. It sits inside somebody else’s script as one guard among several, which is exactly why it gets dropped, and why discounting a gift card is a merchant support ticket rather than a rounding error.

Ricostruito
Cosa faceva lo Script

It skipped any line whose product was a gift card.

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
Il Ruby originale

DISCOUNT_PERCENTAGE = 15

Input.cart.line_items.each do |line_item|
  next if line_item.variant.product.gift_card?
  line_item.change_line_price(
    line_item.line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0)),
    message: "15% off"
  )
end

Output.cart = Input.cart
In cosa si trasforma

Riconosciuto 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.

Ogni impostazione, nel dettaglio
ImpostazioneValoreChiave di configurazione
Offer typevolumetype
Countingper_productcounting
Recurrenceoncerecurrence
Tier 1min qty 1 -> 15% offtiers[0]
Target scopealltarget.scope
MethodautomaticdiscountMethod
Allocationstandardstacking.allocation
Combines with other discountsnostacking
Ti verrà chiesta una conferma
  • Your Script skipped gift cards. We cannot detect gift cards yet, so exclude them by hand in targeting before publishing.
  • Confirm which products this applies to. We could not read product targeting from the script.
Ti verrà comunicato
  • Your Script skipped gift cards and we cannot detect them, so gift cards are discounted unless you exclude them in targeting.
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.
Braided USB-C Cable1$14.00
Subtotale$14.00
Sconto-$2.10
Totale$11.90

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 1 di Braided USB-C Cable a $14.00 e la risposta è fissata.

Lo sconto è $2.10. Il totale pagato dal cliente è $11.90.

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

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 $2.10 off, and checkout charges $11.90.
What will I have to check before publishing?
Your Script skipped gift cards. We cannot detect gift cards yet, so exclude them by hand in targeting before publishing. Confirm which products this applies to. We could not read product targeting from the script. Your Script skipped gift cards and we cannot detect them, so gift cards are discounted unless you exclude them in targeting.

Forme di Script correlate

Scoped to a tag or vendor

A discount limited to products carrying one tag, vendor or type.

Exclude sale items

Already-marked-down products protected from a second discount.

Line item property

A discount keyed on a property attached to one cart line.

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.