Migrating a discount code pattern script
Worth knowing that Shopify Scripts had no regular expressions at all, so every one of these matched by hand with start_with or a substring check on the code.
Noch nicht möglichIt matched any code beginning with a given prefix and applied one rule to all of them.
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.
Das Script
Noch nicht möglichCODE_PREFIX = "STAFF-"
DISCOUNT_PERCENTAGE = 30
code = Input.cart.discount_code
unless code.nil?
if code.code.upcase.start_with?(CODE_PREFIX)
Input.cart.line_items.each do |line_item|
line_item.change_line_price(
line_item.line_price * (1.0 - (DISCOUNT_PERCENTAGE / 100.0)),
message: "Staff discount"
)
end
end
end
Output.cart = Input.cartWe have not built this yet
Your Script matched a whole family of discount codes by prefix or wildcard. Our codes are exact, one at a time.
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.codePattern
Hier gibt es keinen Warenkorb zum Testen, weil nichts gebaut wird. Das Einfügen erzeugt die obige Meldung und überhaupt keine Kampagne.
Häufige Fragen
- Will Stackable rebuild this script?
- No, and the reason is stated rather than hidden: Your Script matched a whole family of discount codes by prefix or wildcard. Our codes are exact, one at a time.
Verwandte Script-Formen
A code the shopper typed, turned away at checkout with a message.
Script logic that only ran when the shopper had typed a particular code.
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.