Migrating a reject discount code script
This one changed under everyone’s feet. Rejecting a typed code was impossible for a discount function until December 2025 and is possible now, with one restriction that decides whether your file can be rebuilt.
Stöds inte änIt rejected the discount code the shopper had entered and showed them a reason.
Klistra in det i Scripts-räddning och se vad som byggs
- Kopiera Ruby-koden med knappen bredvid vilket Script som helst på sidan.
- Öppna Stackable i Shopify-adminen, sedan Verktyg, sedan Scripts-räddning.
- Klistra in det där, läs vad verktyget säger att det ska bygga och jämför med inställningarna på den här sidan.
Scripts-räddning ingår i Pro-planen. Ingenting publiceras förrän du anger vad ditt gamla Script gav i rabatt och båda beloppen stämmer på öret.
Detta Script
Stöds inte änREJECTION_MESSAGE = "Discount codes cannot be used during a sale"
unless Input.cart.discount_code.nil?
Input.cart.discount_code.reject(message: REJECTION_MESSAGE)
end
Output.cart = Input.cartWe have not built this yet
Your Script turned away a discount code the shopper typed. Shopify allows that only from an automatic discount, so we can rebuild it if this campaign runs automatically rather than on its own code.
Det här är vår lucka, inte Shopifys. Shopify tillåter det och vi har inte byggt det, så det finns inget att länka till här och inget att skylla på plattformen.
Orsaksnyckel: unsupported.rejectDiscountCodeOnCodeCampaign
Det finns ingen varukorg att testa här, eftersom ingenting byggs. Att klistra in det här ger meddelandet ovan och ingen kampanj alls.
Vanliga frågor
- Will Stackable rebuild this script?
- No, and the reason is stated rather than hidden: Your Script turned away a discount code the shopper typed. Shopify allows that only from an automatic discount, so we can rebuild it if this campaign runs automatically rather than on its own code.
Besläktade Script-former
Script logic that only ran when the shopper had typed a particular code.
A whole family of codes driving one rule through a prefix match.
Klistra in ditt Script och se det byggas om
Ombyggnaden stäms av mot beloppet som ditt gamla Script tog ut innan du kan publicera den.