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.
NachgebautIt skipped any line whose product was already marked down.
Händler haben das auf 2 verschiedene Arten geschrieben, und sie bedeuten nicht alle dasselbe. Jede Schreibweise steht unten mit eigenem Warenkorb und eigenen Zahlen.
Fügen Sie es in die Scripts-Rettung ein und sehen Sie, was daraus wird
- Kopieren Sie das Ruby mit der Schaltfläche neben jedem Script auf dieser Seite.
- Öffnen Sie im Shopify-Adminbereich Stackable, dann Tools, dann Scripts-Rettung.
- 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.
Exclude sale items tag proxy (D8)
NachgebautGefährliches Paar D8. Diese Datei und ihr Gegenstück sehen fast gleich aus und verhalten sich unterschiedlich, lesen Sie also beide, bevor Sie entscheiden, welche Sie haben.
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.cartErkannt 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.
| Einstellung | Wert | Konfigurationsschlüssel |
|---|---|---|
| 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.
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.
- 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.
| Artikel | Menge | Einzelpreis |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| Zwischensumme | $14.00 | |
| Rabatt | -$1.40 | |
| Summe | $12.60 | |
Nicht angemeldet oder als Kunde ohne Tags angemeldet.
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 $1.40. Der Betrag, den der Käufer gezahlt hat, ist $12.60.
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.
- swap the cart for a single Ceramic Travel Mug
| Artikel | Menge | Einzelpreis |
|---|---|---|
| Ceramic Travel Mug | 1 | $22.00 |
| Zwischensumme | $22.00 | |
| Summe | $22.00 | |
Nicht angemeldet oder als Kunde ohne Tags angemeldet.
Exclude sale items compare at (D8)
Noch nicht möglichGefährliches Paar D8. Diese Datei und ihr Gegenstück sehen fast gleich aus und verhalten sich unterschiedlich, lesen Sie also beide, bevor Sie entscheiden, welche Sie haben.
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.
Das ist unsere Lücke, nicht die von Shopify. Shopify erlaubt es, und wir haben es nicht gebaut. Es gibt hier also nichts zu verlinken und nichts, was man der Plattform anlasten könnte.
Grundschlüssel: unsupported.compareAtExclusion
Hier gibt es keinen Warenkorb zum Testen, weil nichts gebaut wird. Das Einfügen erzeugt die obige Meldung und überhaupt keine Kampagne.
Zwei Dateien, die gleich aussehen
Jedes Paar unten ist dieselbe Script-Form in zwei Schreibweisen. Sie unterscheiden sich in ein, zwei Zeilen und tun Unterschiedliches. Lesen Sie beide, bevor Sie entscheiden, welche Sie haben.
Gefährliches Paar D8
Exclude sale items tag proxy (D8)
NachgebautWird als volume-Angebot nachgebaut.
Rabatt im eigenen Warenkorb: $1.40
next if line_item.variant.product.tags.include?("sale")Exclude sale items compare at (D8)
Noch nicht möglichKein Nachbau. We have not built this yet
next if line_item.variant.compare_at_price && line_item.variant.compare_at_price > line_item.variant.priceHäufige Fragen
- 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.
Verwandte Script-Formen
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.
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.