Zum Inhalt springen
Script-Beispiele

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.

Nachgebaut
Was das Script gemacht hat

It skipped any line whose product was a gift card.

Im eigenen Shop ausprobieren

Fügen Sie es in die Scripts-Rettung ein und sehen Sie, was daraus wird

  1. Kopieren Sie das Ruby mit der Schaltfläche neben jedem Script auf dieser Seite.
  2. Öffnen Sie im Shopify-Adminbereich Stackable, dann Tools, dann Scripts-Rettung.
  3. Fügen Sie es dort ein, lesen Sie, was das Tool bauen will, und vergleichen Sie das mit den Einstellungen auf dieser Seite.

Die Scripts-Rettung gehört zum Pro-Tarif. Nichts wird veröffentlicht, bevor Sie angeben, was Ihr altes Script berechnet hat, und beide Zahlen auf den Cent genau übereinstimmen.

Das Script

Nachgebaut
Das ursprüngliche Ruby

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
Was daraus wird

Erkannt als Percentage off und neu aufgebaut als Angebot vom Typ volume. Das sind die echten Konfigurationsschlüssel, mit denen das Angebot gespeichert wird, sodass Sie Ihren eigenen Nachbau Feld für Feld damit abgleichen können.

Jede Einstellung im Detail
EinstellungWertKonfigurationsschlüssel
Offer typevolumetype
Countingper_productcounting
Recurrenceoncerecurrence
Tier 1min qty 1 -> 15% offtiers[0]
Target scopealltarget.scope
MethodautomaticdiscountMethod
Allocationstandardstacking.allocation
Combines with other discountsnostacking
Sie werden um Bestätigung gebeten
  • 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.
Sie werden darauf hingewiesen
  • Your Script skipped gift cards and we cannot detect them, so gift cards are discounted unless you exclude them in targeting.
Der Warenkorb, der es belegt

Aufgebaut in unserem öffentlichen Demo-Shop Meridian Goods, damit sich jeder Preis hier nachrechnen lässt und nicht geglaubt werden muss. Der Rabatt unten ist das, was dieselbe Engine, die im Checkout läuft, für genau diesen Warenkorb berechnet.

Der Warenkorb, der dieses Angebot auslöst, und was es kostet
ArtikelMengeEinzelpreis
Braided USB-C Cable1$14.00
Zwischensumme$14.00
Rabatt-$2.10
Summe$11.90

Nicht angemeldet oder als Kunde ohne Tags angemeldet.

Die Zahl, an der das Tool Sie misst

Vor dem Veröffentlichen fragt das Tool, was Ihr altes Script mit einem Warenkorb gemacht hat, den Sie bereits haben. Stellen Sie ihn auf 1 von Braided USB-C Cable zu $14.00 ein, dann steht die Antwort fest.

Der Rabatt beträgt $2.10. Der Betrag, den der Käufer gezahlt hat, ist $11.90.

Der Vergleich ist exakt, bis auf die kleinste Einheit Ihrer Währung. Ein Cent daneben und das Veröffentlichen bleibt gesperrt, genau darum geht es bei diesem Schritt.

Der Warenkorb, der nichts auslösen darf

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.

Häufige Fragen

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.

Verwandte Script-Formen

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.

Fügen Sie Ihr Script ein und sehen Sie den Nachbau

Der Nachbau wird mit dem Betrag abgeglichen, den Ihr altes Script berechnet hat, bevor Sie ihn veröffentlichen können.

Wir verwenden essenzielle Cookies für den Betrieb dieser Website und, nur mit Ihrer Erlaubnis, Analyse-Cookies, um den Traffic zu verstehen. Lesen Sie unsere Cookie-Richtlinie.