Naar de inhoud
Script-voorbeelden

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.

Herbouwd
Wat het Script deed

It inspected the discount code the shopper had entered and branched on it.

Probeer het in je eigen winkel

Plak het in Scripts-redding en kijk wat eruit komt

  1. Kopieer de Ruby met de knop naast elk Script op deze pagina.
  2. Open in je Shopify-beheer Stackable, dan Hulpmiddelen, dan Scripts-redding.
  3. 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

Herbouwd
De oorspronkelijke Ruby

BONUS_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.cart
Wat het wordt

Herkend 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.

Elke instelling, uitgeschreven
InstellingWaardeConfiguratiesleutel
Offer typevolumetype
Countingper_productcounting
Recurrenceoncerecurrence
Tier 1min qty 1 -> 10% offtiers[0]
Target scopealltarget.scope
MethodcodediscountMethod
Allocationstandardstacking.allocation
Combines with other discountsnostacking
Er wordt om bevestiging gevraagd
  • Confirm which products this applies to. We could not read product targeting from the script.
De winkelwagen die het bewijst

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.

De winkelwagen die deze aanbieding activeert, en wat die kost
ArtikelAantalStukprijs
Braided USB-C Cable1$14.00
Subtotaal$14.00
Korting-$1.40
Totaal$12.60

Uitgelogd, of ingelogd als klant zonder tags.

Het bedrag waaraan de tool je toetst

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.

De winkelwagen die niets mag opleveren

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

Reject a discount code

A code the shopper typed, turned away at checkout with a message.

Discount code pattern

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.

We gebruiken essentiële cookies om deze site te laten werken en, alleen met uw toestemming, analytische cookies om verkeer te begrijpen. Lees ons Cookiebeleid.