Spring til indhold
Script-eksempler

Migrating a free shipping for tagged customers script

Shopify shipped this in its own repo. The gate lowercased both sides of the tag comparison; Shopify matches tags exactly, so a tag typed VIP in one place and vip in the other is a silent no-op.

Genopbygget
Hvad dette Script gjorde

It made delivery free for shoppers whose customer record carried a particular tag.

Prøv det i din egen butik

Indsæt det i Scripts-redning, og se hvad der bliver bygget

  1. Kopiér Ruby-koden med knappen ved siden af ethvert Script på siden.
  2. Åbn Stackable i Shopify-administrationen, derefter Værktøjer og så Scripts-redning.
  3. 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

Genopbygget
Den oprindelige Ruby-kode

VIP_TAG = "VIP"

if !Input.cart.customer.nil? && Input.cart.customer.tags.include?(VIP_TAG)
  Input.shipping_rates.each do |shipping_rate|
    shipping_rate.apply_discount(shipping_rate.price, message: "Free shipping for VIP")
  end
end

Output.shipping_rates = Input.shipping_rates
Hvad det bliver til

Genkendt som Shipping discount og genopbygget som et tilbud af typen free_shipping. Det her er de rigtige konfigurationsnøgler, som tilbuddet gemmes med, så du kan tjekke din egen genopbygning felt for felt.

Hver indstilling, skrevet ud
IndstillingVærdiKonfigurationsnøgle
Offer typefree_shippingtype
Countingper_cartcounting
Recurrenceoncerecurrence
Tier 1min spend $0.00 -> 100% offtiers[0]
Target scopealltarget.scope
Customer scopetagscustomerTarget.scope
Customer tagsVIPcustomerTarget.ids
MethodautomaticdiscountMethod
Allocationstandardstacking.allocation
Combines with other discountsnostacking
Du bliver bedt om at bekræfte
  • This script only applied to tagged customers. Set customer eligibility in the builder before publishing.
  • Confirm which products this applies to. We could not read product targeting from the script.
Du får det at vide
  • This discounts every shipping rate at checkout, not one named rate.
  • Shopify matches customer tags exactly, including capital letters, while your Script lowercased them. Check the spelling of the tag before you publish.
Kurven, der beviser det

Bygget i vores offentlige demobutik, Meridian Goods, så hver pris her kan efterregnes i stedet for at blive taget på tro. Rabatten nedenfor er det, som den samme motor, der kører i kassen, beregner for præcis denne kurv.

Kurven, der udløser dette tilbud, og hvad det koster
VareAntalStykpris
Braided USB-C Cable1$14.00
Subtotal$14.00
Levering, normalt $6.90$0.00
Total$14.00

Logget ind som kunde med tagget VIP.

Beløbet, som værktøjet holder dig op mod

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.

Kurven, der ikke må give noget
  • take the same cart, but sign in as the customer with no tags
Kurven, der ikke må udløse dette tilbud
VareAntalStykpris
Braided USB-C Cable1$14.00
Subtotal$14.00
Total$14.00

Logget ud, eller logget ind som kunde uden tags.

Ofte stillede spørgsmål

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 $6.90 off, and checkout charges $14.00 plus $0.00 delivery.
What will I have to check before publishing?
This script only applied to tagged customers. Set customer eligibility in the builder 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. Shopify matches customer tags exactly, including capital letters, while your Script lowercased them. Check the spelling of the tag before you publish.

Beslægtede Script-typer

Percentage off shipping

A share taken off every delivery rate at checkout.

Amount off shipping

A flat sum off the delivery charge, floored at free.

Flat rate shipping

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

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.

Vi bruger essentielle cookies til at drive dette site, og kun med din tilladelse, analysecookies til at forstå trafik. Læs vores Cookiepolitik.