Vai al contenuto
Esempi di Script

Migrating a customer tag discount script

Nine independent sources write this the same way, and one very common variant is simply broken: it asks whether an array of tags is an ELEMENT of another array, which is never true, so the discount never fired for anyone.

Ricostruito
Cosa faceva lo Script

It applied the discount only when the signed-in customer carried one of the listed tags.

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.

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.

Customer tag gate, set intersection

Ricostruito
Il Ruby originale

CUSTOMER_TAGS = ["vip", "wholesale"]
DISCOUNT_PERCENTAGE = 25

customer = Input.cart.customer

unless customer.nil?
  if !(CUSTOMER_TAGS & customer.tags.map(&:downcase)).empty?
    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: "Member pricing"
      )
    end
  end
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 -> 25% offtiers[0]
Target scopealltarget.scope
Customer scopetagscustomerTarget.scope
Customer tagsvip, wholesalecustomerTarget.ids
MethodautomaticdiscountMethod
Allocationstandardstacking.allocation
Combines with other discountsnostacking
Ti verrà chiesta una conferma
  • This script only applied to tagged customers. Set customer eligibility in the builder 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.
Ti verrà comunicato
  • Shopify matches customer tags exactly, including capital letters, while your Script lowercased them. Check the spelling of the tag before you publish.
  • 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-$3.50
Totale$10.50

Accesso effettuato come cliente con tag vip, wholesale.

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 è $3.50. Il totale pagato dal cliente è $10.50.

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
  • take the same cart, but sign in as the customer with no tags
Il carrello che non deve attivare questa offerta
ArticoloQtàPrezzo unit.
Braided USB-C Cable1$14.00
Subtotale$14.00
Totale$14.00

Nessun accesso, oppure accesso come cliente senza tag.

Customer tag gate, broken include

Controlla il testo
Il Ruby originale

TAGS_NEEDED = ["vip", "wholesale"]

Input.cart.line_items.each do |line_item|
  next unless TAGS_NEEDED.include?(line_item.variant.product.tags)
  line_item.change_line_price(line_item.line_price * 0.8, message: "20% off")
end

Output.cart = Input.cart
Cosa succede a questo

We could not read this copy of your Script

This does not look like a Shopify Script. Paste the Ruby from the Script Editor, starting with the settings at the top of the file.

Il tuo Script probabilmente va benissimo. Quello che non va è la copia che arriva allo strumento, e da un file danneggiato non tirerà a indovinare i prezzi.

Chiave del motivo: input.notAScript

Qui non c'è nessun carrello da testare, perché non viene creato nulla. Incollando questo compare il messaggio qui sopra e nessuna campagna.

Domande 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 $3.50 off, and checkout charges $10.50.
What will I have to check before publishing?
This script only applied to tagged customers. Set customer eligibility in the builder 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. Shopify matches customer tags exactly, including capital letters, while your Script lowercased them. Check the spelling of the tag before you publish. Your Script skipped gift cards and we cannot detect them, so gift cards are discounted unless you exclude them in targeting.
What happens to the part you cannot rebuild?
We could not read this copy of your Script. This does not look like a Shopify Script. Paste the Ruby from the Script Editor, starting with the settings at the top of the file.

Forme di Script correlate

First order discount

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

First time customer, cheapest item

A new-customer gate wrapped around a cheapest-item reward.

Lifetime spend discount

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

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.