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.
NachgebautIt made delivery free for shoppers whose customer record carried a particular tag.
Fügen Sie es in die Scripts-Rettung ein und sehen Sie, was daraus wird
- Kopieren Sie das Ruby mit der Schaltfläche neben jedem Script auf dieser Seite.
- Öffnen Sie im Shopify-Adminbereich Stackable, dann Tools, dann Scripts-Rettung.
- Fügen Sie es dort ein, lesen Sie, was das Tool bauen will, und vergleichen Sie das mit den Einstellungen auf dieser Seite.
Die Scripts-Rettung gehört zum Pro-Tarif. Nichts wird veröffentlicht, bevor Sie angeben, was Ihr altes Script berechnet hat, und beide Zahlen auf den Cent genau übereinstimmen.
Das Script
NachgebautVIP_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_ratesErkannt als Shipping discount und neu aufgebaut als Angebot vom Typ free_shipping. Das sind die echten Konfigurationsschlüssel, mit denen das Angebot gespeichert wird, sodass Sie Ihren eigenen Nachbau Feld für Feld damit abgleichen können.
| Einstellung | Wert | Konfigurationsschlüssel |
|---|---|---|
| Offer type | free_shipping | type |
| Counting | per_cart | counting |
| Recurrence | once | recurrence |
| Tier 1 | min spend $0.00 -> 100% off | tiers[0] |
| Target scope | all | target.scope |
| Customer scope | tags | customerTarget.scope |
| Customer tags | VIP | customerTarget.ids |
| Method | automatic | discountMethod |
| Allocation | standard | stacking.allocation |
| Combines with other discounts | no | stacking |
- 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.
Aufgebaut in unserem öffentlichen Demo-Shop Meridian Goods, damit sich jeder Preis hier nachrechnen lässt und nicht geglaubt werden muss. Der Rabatt unten ist das, was dieselbe Engine, die im Checkout läuft, für genau diesen Warenkorb berechnet.
| Artikel | Menge | Einzelpreis |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| Zwischensumme | $14.00 | |
| Lieferung, normalerweise $6.90 | $0.00 | |
| Summe | $14.00 | |
Angemeldet als Kunde mit dem Tag VIP.
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.
- take the same cart, but sign in as the customer with no tags
| Artikel | Menge | Einzelpreis |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| Zwischensumme | $14.00 | |
| Summe | $14.00 | |
Nicht angemeldet oder als Kunde ohne Tags angemeldet.
Häufige Fragen
- 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.
Verwandte Script-Formen
A share taken off every delivery rate at checkout.
A flat sum off the delivery charge, floored at free.
Every delivery rate rewritten to one price rather than reduced by an amount.
Fügen Sie Ihr Script ein und sehen Sie den Nachbau
Der Nachbau wird mit dem Betrag abgeglichen, den Ihr altes Script berechnet hat, bevor Sie ihn veröffentlichen können.