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.
可重建It made delivery free for shoppers whose customer record carried a particular tag.
把它粘贴到 Scripts 救援,看看会重建成什么
- 用本页任意 Script 旁边的按钮复制 Ruby 代码。
- 在 Shopify 后台打开 Stackable,依次进入工具、Scripts 救援。
- 粘贴进去,读一读工具说它会创建什么,再和本页的设置逐项对照。
Scripts 救援属于 Pro 套餐。在您填写旧 Script 的折扣金额、且两个数字精确到最小货币单位完全一致之前,不会发布任何内容。
Script 本体
可重建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识别为 Shipping discount,重建为 free_shipping 类型的优惠。下面是优惠实际保存时使用的配置键,您可以逐项核对自己的重建结果。
| 设置项 | 值 | 配置键 |
|---|---|---|
| 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.
基于我们的公开演示店铺 Meridian Goods 搭建,因此这里的每个价格都可以复现,而不必凭信任接受。下方的折扣金额,是结账时运行的同一个引擎针对这个购物车算出的结果。
| 商品 | 数量 | 单价 |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| 小计 | $14.00 | |
| 配送,通常为 $6.90 | $0.00 | |
| 总额 | $14.00 | |
以带有标签 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
| 商品 | 数量 | 单价 |
|---|---|---|
| Braided USB-C Cable | 1 | $14.00 |
| 小计 | $14.00 | |
| 总额 | $14.00 | |
未登录,或以没有标签的客户身份登录。
常见问题
- 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.
相关的 Script 类型
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.