Migrating a flat rate shipping script
Setting a rate TO a price and taking an amount OFF a rate need different information: the second needs only the discount, the first needs the rate’s own cost. That difference is the whole entry.
Ikke understøttet endnuIt rewrote every delivery rate to one flat price.
Indsæt det i Scripts-redning, og se hvad der bliver bygget
- Kopiér Ruby-koden med knappen ved siden af ethvert Script på siden.
- Åbn Stackable i Shopify-administrationen, derefter Værktøjer og så Scripts-redning.
- Indsæt det der, læs hvad værktøjet siger, det vil bygge, og hold det op mod indstillingerne på denne side.
Scripts-redning hører til Pro-abonnementet. Intet bliver udgivet, før du oplyser, hvad dit gamle Script gav i rabat, og de to beløb stemmer helt ned på øret.
Selve dette Script
Ikke understøttet endnuFarligt par D4. Denne fil og dens makker ser næsten ens ud og opfører sig forskelligt, så læs dem begge, før du afgør, hvilken du har.
# GENERATED BY THE SHOPIFY SCRIPT CREATOR APP
class FixedPriceDiscount
def initialize(amount, message)
@amount = Money.new(cents: 100) * amount
@message = message
end
def apply(rate)
rate_discount = @amount > rate.price ? rate.price : rate.price - @amount
rate.apply_discount(rate_discount, { message: @message })
end
end
CAMPAIGNS = [
ShippingDiscount.new(:all, nil, nil, FixedPriceDiscount.new(5, "Flat rate shipping $5")),
].freeze
CAMPAIGNS.each do |campaign|
campaign.run(Input.shipping_rates, Input.cart)
end
Output.shipping_rates = Input.shipping_ratesWe have not built this yet
Your Script set shipping to a fixed price. We can take an amount or a percentage off shipping, but setting a rate to a price needs the rate's own cost, which we do not read yet.
Det her er vores hul, ikke Shopifys. Shopify tillader det, og vi har ikke bygget det, så der er intet at linke til her og intet at skyde på platformen.
Årsagsnøgle: unsupported.shippingFixedPrice
Der er ingen kurv at teste her, fordi der ikke bliver bygget noget. At indsætte det her giver beskeden ovenfor og slet ingen kampagne.
To filer, der ligner hinanden
Hvert par herunder er den samme Script-form skrevet på to måder. De adskiller sig på en eller to linjer og gør noget forskelligt, så læs dem begge, før du afgør, hvilken du har.
Farligt par D4
Shipping fixed price (D4)
Ikke understøttet endnuBygges ikke om. We have not built this yet
class FixedPriceDiscount
rate_discount = @amount > rate.price ? rate.price : rate.price - @amount
ShippingDiscount.new(:all, nil, nil, FixedPriceDiscount.new(5, "Flat rate shipping $5")),Shipping fixed amount off (D4)
GenopbyggetBygges om til et free_shipping-tilbud.
Fragtbesparelse i dens egen kurv: $5.00
class FixedDiscount
rate_discount = rate.price - @amount < Money.zero ? rate.price : @amount
ShippingDiscount.new(:all, nil, nil, FixedDiscount.new(5, "$5 off shipping")),Ofte stillede spørgsmål
- Will Stackable rebuild this script?
- No, and the reason is stated rather than hidden: Your Script set shipping to a fixed price. We can take an amount or a percentage off shipping, but setting a rate to a price needs the rate's own cost, which we do not read yet.
Beslægtede Script-typer
A flat sum off the delivery charge, floored at free.
A share taken off every delivery rate at checkout.
Delivery drops to free once the cart is worth enough.
Indsæt dit Script og se det blive genopbygget
Genopbygningen holdes op mod det beløb, dit gamle Script opkrævede, før du kan udgive den.