Skip to content
Scripts examples

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.

Rebuilt
What the Script did

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

Run it against your own store

Paste it into Scripts rescue and watch what it rebuilds

  1. Copy the Ruby with the button beside any Script on this page.
  2. In your Shopify admin, open Stackable, then Tools, then Scripts rescue.
  3. Paste it there, read what the tool says it will build, and compare that with the settings on this page.

Scripts rescue is on the Pro plan. Nothing is published until you tell it what your old Script charged and the two figures match to the cent.

The Script

Rebuilt
The original Ruby

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
What it becomes

Recognised as Shipping discount and rebuilt as a free_shipping offer. These are the real configuration keys the offer is saved with, so you can check your own rebuild against them field by field.

Every setting, spelled out
SettingValueConfig key
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
You will be asked to confirm
  • 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.
You will be told
  • 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.
The cart that proves it

Built on our public demo store, Meridian Goods, so every price here can be reproduced rather than taken on trust. The discount below is what the same engine that runs at checkout computes for this exact cart.

The cart that triggers this offer, and what it costs
ItemQtyUnit price
Braided USB-C Cable1$14.00
Subtotal$14.00
Delivery, normally $6.90$0.00
Total$14.00

Signed in as a customer tagged VIP.

The figure the tool checks you against

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.

The cart that must produce nothing
  • take the same cart, but sign in as the customer with no tags
The cart that must not trigger this offer
ItemQtyUnit price
Braided USB-C Cable1$14.00
Subtotal$14.00
Total$14.00

Signed out, or signed in as a customer with no tags.

Common questions

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.

Related Script shapes

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.

Paste your Script and see it rebuilt

The rebuild is checked against the money your old Script charged before you can publish it.

We use essential cookies to run this site, and, only with your permission, analytics cookies to understand traffic. Read our Cookie Policy.