Migrating an exclude sale items script
The same intent, often the same comment in the merchant’s own file, and two completely different answers depending on how the markdown was detected. Getting the pair backwards either refuses something we support or leaks margin on every clearance line.
RicostruitoIt skipped any line whose product was already marked down.
I merchant lo hanno scritto in 2 modi diversi, e non significano tutti la stessa cosa. Ogni variante è riportata sotto con il proprio carrello e i propri numeri.
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.
Exclude sale items tag proxy (D8)
RicostruitoCoppia rischiosa D8. Questo file e il suo gemello sembrano quasi identici e si comportano in modo diverso, quindi leggili entrambi prima di decidere quale hai.
DISCOUNT_PERCENTAGE = 10
Input.cart.line_items.each do |line_item|
next if line_item.variant.product.tags.include?("sale")
new_price = line_item.original_line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0))
line_item.change_line_price(new_price, message: "10% off full-price items")
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 |
| Target excludes | sale | target.excludeIds |
| Method | automatic | discountMethod |
| Allocation | standard | stacking.allocation |
| Combines with other discounts | no | stacking |
- Your Script limited this to a tag, vendor, or product type. We carried that filter over, so confirm it selects the products you expect.
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.
- Targeting excludes sale. No Meridian Goods product carries those, so every product stays eligible and the exclusion is proved by the campaign settings, not by the cart.
| 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.
- swap the cart for a single Ceramic Travel Mug
| Articolo | Qtà | Prezzo unit. |
|---|---|---|
| Ceramic Travel Mug | 1 | $22.00 |
| Subtotale | $22.00 | |
| Totale | $22.00 | |
Nessun accesso, oppure accesso come cliente senza tag.
Exclude sale items compare at (D8)
Non ancora supportatoCoppia rischiosa D8. Questo file e il suo gemello sembrano quasi identici e si comportano in modo diverso, quindi leggili entrambi prima di decidere quale hai.
DISCOUNT_PERCENTAGE = 10
Input.cart.line_items.each do |line_item|
next if line_item.variant.compare_at_price && line_item.variant.compare_at_price > line_item.variant.price
new_price = line_item.original_line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0))
line_item.change_line_price(new_price, message: "10% off full-price items")
end
Output.cart = Input.cartWe have not built this yet
Your Script skipped items that were already marked down. Shopify does give us the sale price, but our checkout query is already at Shopify's cost limit, so we cannot ask for it today. Exclude those products by hand and we can rebuild the rest.
È una mancanza nostra, non di Shopify. Shopify lo consente e noi non lo abbiamo realizzato, quindi qui non c'è niente da collegare e niente da addossare alla piattaforma.
Chiave del motivo: unsupported.compareAtExclusion
Qui non c'è nessun carrello da testare, perché non viene creato nulla. Incollando questo compare il messaggio qui sopra e nessuna campagna.
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 D8
Exclude sale items tag proxy (D8)
RicostruitoRicostruito come offerta volume.
Sconto sul suo carrello: $1.40
next if line_item.variant.product.tags.include?("sale")Exclude sale items compare at (D8)
Non ancora supportatoNon ricostruito. We have not built this yet
next if line_item.variant.compare_at_price && line_item.variant.compare_at_price > line_item.variant.priceDomande frequenti
- Will Stackable rebuild this script?
- It depends on how yours is written. 1 of the 2 spellings on this page are rebuilt today; the rest are refused with a reason. Compare your file against the Ruby above.
- 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?
- Your Script limited this to a tag, vendor, or product type. We carried that filter over, so confirm it selects the products you expect.
- What happens to the part you cannot rebuild?
- We have not built this yet. Your Script skipped items that were already marked down. Shopify does give us the sale price, but our checkout query is already at Shopify's cost limit, so we cannot ask for it today. Exclude those products by hand and we can rebuild the rest.
Forme di Script correlate
A discount limited to products carrying one tag, vendor or type.
Gift cards left out of a discount that would otherwise have hit them.
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.