Migrating a discount code driven script
The script did not own the code; a native Shopify discount did, and the script watched for it. A rebuilt offer owns its code outright, which is the same shopper experience through a different mechanism.
HerbouwdIt inspected the discount code the shopper had entered and branched on it.
Plak het in Scripts-redding en kijk wat eruit komt
- Kopieer de Ruby met de knop naast elk Script op deze pagina.
- Open in je Shopify-beheer Stackable, dan Hulpmiddelen, dan Scripts-redding.
- Plak het daar, lees wat het hulpmiddel zegt te gaan bouwen en vergelijk dat met de instellingen op deze pagina.
Scripts-redding zit in het Pro-abonnement. Er wordt niets gepubliceerd totdat je vertelt wat je oude Script gaf en beide bedragen tot op de cent kloppen.
Het Script
HerbouwdBONUS_PERCENTAGE = 10
code = Input.cart.discount_code
unless code.nil?
case code
when CartDiscount::Percentage
if code.code == "VIP20"
Input.cart.line_items.each do |line_item|
line_item.change_line_price(
line_item.line_price * (1.0 - (BONUS_PERCENTAGE / 100.0)),
message: "Extra 10% with VIP20"
)
end
end
end
end
Output.cart = Input.cartHerkend als Percentage off en herbouwd als aanbieding van het type volume. Dit zijn de echte configuratiesleutels waarmee de aanbieding wordt opgeslagen, zodat je je eigen herbouw veld voor veld kunt nalopen.
| Instelling | Waarde | Configuratiesleutel |
|---|---|---|
| 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 |
| Method | code | discountMethod |
| Allocation | standard | stacking.allocation |
| Combines with other discounts | no | stacking |
- Confirm which products this applies to. We could not read product targeting from the script.
Gebouwd in onze openbare demowinkel, Meridian Goods, zodat elke prijs hier na te rekenen is in plaats van op vertrouwen aangenomen. De korting hieronder is wat dezelfde engine die bij het afrekenen draait, voor precies deze winkelwagen berekent.
| Artikel | Aantal | Stukprijs |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| Subtotaal | $14.00 | |
| Korting | -$1.40 | |
| Totaal | $12.60 | |
Uitgelogd, of ingelogd als klant zonder tags.
Voor het publiceren vraagt de tool wat je oude Script deed met een winkelwagen die je al hebt. Zet die op 1 van Braided USB-C Cable voor $14.00 en het antwoord ligt vast.
De korting is $1.40. Het totaal dat de klant betaalde is $12.60.
De vergelijking is exact, tot op de kleinste eenheid van je valuta. Eén cent ernaast en publiceren blijft dicht, en daar gaat deze stap juist om.
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.
Veelgestelde vragen
- 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 $1.40 off, and checkout charges $12.60.
- What will I have to check before publishing?
- Confirm which products this applies to. We could not read product targeting from the script.
Verwante Script-vormen
A code the shopper typed, turned away at checkout with a message.
A whole family of codes driving one rule through a prefix match.
Plak je Script en zie het herbouwd worden
De herbouw wordt getoetst aan het bedrag dat je oude Script rekende voordat je hem kunt publiceren.