Naar de inhoud
Script-voorbeelden

Migrating an amount off shipping script

Two classes in the generator library are one word apart and inverted. On a $30 rate, one leaves the shopper paying $25 and the other leaves them paying $5, and the bodies are almost the same ternary.

Herbouwd
Wat het Script deed

It subtracted a fixed sum from every delivery rate, never taking it below free.

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

Riskant paar D4. Dit bestand en zijn tegenhanger zien er bijna hetzelfde uit en doen iets anders, dus lees ze allebei voordat je bepaalt welke jij hebt.

De oorspronkelijke Ruby

# GENERATED BY THE SHOPIFY SCRIPT CREATOR APP

class FixedDiscount
  def initialize(amount, message)
    @amount = Money.new(cents: 100) * amount
    @message = message
  end

  def apply(rate)
    rate_discount = rate.price - @amount < Money.zero ? rate.price : @amount
    rate.apply_discount(rate_discount, { message: @message })
  end
end

CAMPAIGNS = [
  ShippingDiscount.new(:all, nil, nil, FixedDiscount.new(5, "$5 off shipping")),
].freeze

CAMPAIGNS.each do |campaign|
  campaign.run(Input.shipping_rates, Input.cart)
end

Output.shipping_rates = Input.shipping_rates
Wat het wordt

Herkend als Shipping discount en herbouwd als aanbieding van het type free_shipping. 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 typefree_shippingtype
Countingper_cartcounting
Recurrenceoncerecurrence
Tier 1min spend $0.00 -> $5.00 off eachtiers[0]
Target scopealltarget.scope
MethodautomaticdiscountMethod
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.
Je krijgt te horen
  • This discounts every shipping rate at checkout, not one named rate.
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
Bezorging, normaal $6.90$1.90
Totaal$14.00

Uitgelogd, of ingelogd als klant zonder tags.

Het bedrag waaraan de tool je toetst

This rebuild only changes shipping. We price shipping against a sample rate rather than the rate your shopper saw, so there is no figure here we could honestly compare. Publishing records that the amount was not checked.

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.

Twee bestanden die op elkaar lijken

Elk paar hieronder is dezelfde Script-vorm, op twee manieren geschreven. Ze schelen een of twee regels en doen iets anders, dus lees ze allebei voordat je bepaalt welke jij hebt.

Gevaarlijk paar D4

Shipping fixed amount off (D4)

Herbouwd

Opnieuw gebouwd als free_shipping-aanbieding.

Verzendvoordeel in de eigen winkelwagen: $5.00

Regels die verschillen
class FixedDiscount
    rate_discount = rate.price - @amount < Money.zero ? rate.price : @amount
  ShippingDiscount.new(:all, nil, nil, FixedDiscount.new(5, "$5 off shipping")),
Amount off shipping lezen

Shipping fixed price (D4)

Nog niet mogelijk

Niet opnieuw gebouwd. We have not built this yet

Regels die verschillen
class FixedPriceDiscount
    rate_discount = @amount > rate.price ? rate.price : rate.price - @amount
  ShippingDiscount.new(:all, nil, nil, FixedPriceDiscount.new(5, "Flat rate shipping $5")),
Flat rate shipping lezen

Veelgestelde vragen

Will Stackable rebuild this script?
Yes. Every spelling on this page is rebuilt today as a free_shipping 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 $5.00 off, and checkout charges $14.00 plus $1.90 delivery.
What will I have to check before publishing?
Confirm which products this applies to. We could not read product targeting from the script. This discounts every shipping rate at checkout, not one named rate.

Verwante Script-vormen

Flat rate shipping

Every delivery rate rewritten to one price rather than reduced by an amount.

Percentage off shipping

A share taken off every delivery rate at checkout.

Free shipping over a threshold

Delivery drops to free once the cart is worth enough.

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.