In this article:

What are Shopify Scripts and Shopify Script Editor?

Shopify Scripts are small pieces of code that let you create personalised experiences for your customers in their cart and at checkout.

You can use scripts to create discounts that are applied to a cart based on the items in that cart as well as other cart properties. You can also use scripts to customise the shipping and payment options that are available to your customers.

Benefits of using Shopify Script Editor

  • Save hours of time - create Scripts
  • Personalisation - use Scripts based on the customer information to deliver a personalised experience
  • Create automatic discounts for your customers without the need to use vouchers - as Shopify only allows one discount voucher code per checkout, you can use Scripts to create automatically applied discounts for your customers (for Black Friday or Seasonal Sales), without the need for your customers to copy and paste a seasonal voucher
  • Set automatic discounts for your customers in specific tiers - set automatic discounts for your customers in specific tiers
  • Experiences instead of points - using LoyaltyLion and Scripts can help you create a "point-less" loyalty program experience for your customers

Checklist

In order to use LoyaltyLion with Shopify Scripts, make sure you tick all the boxes below:

✅ You're using Shopify Plus

✅. Your loyalty tiers are live

✅ You have the Loyalty Tier (customer tag) enabled (click here to read more about our metafields)

How to make sure your Loyalty Tier (customer tag) is enabled?

Our Loyalty Tier (customer tag) falls under our metafields integration. To enable this, please contact support@loyaltylion.com to get it turned on for your account and tell us which metafields you'd like us to sync. Once this is done, we'll start synchronising this information with your Shopify.

If you want to see if the Loyalty Tier (customer tag) is enabled the easiest way is to follow the steps below:

  1. Log into your Shopify admin
  2. Click on the Customers tab

3. Select an enrolled customer from the list

4. In the profile view, scroll down to Tags box

5. Each of your enrolled customers will have a tag "tier: XXX" based on the LoyaltyLion tier they're currently in.

How to use Shopify Script Editor with LoyaltyLion?

Please note that this documentation requires technical knowledge. Please include your developers in the process.

Free shipping for customers in a specific tier

TAG = "tier: Red" #customer tag
MESSAGE = "Red tier Customer Promotion" #additional message
customer = Input.cart.customer

if customer
if customer.tags.include?(TAG)
Input.shipping_rates.each do |shipping_rate|
if shipping_rate.name.include?("Standard Shipping")
shipping_rate.change_name("FREE Red tier GROUND SHIPPING", { message: "" })
shipping_rate.apply_discount(shipping_rate.price, message: MESSAGE)
end
end
end
end

Output.shipping_rates = Input.shipping_rates

Discount by quantity for tier members

DISCOUNTS_BY_QUANTITY = {
50 => 20,
15 => 15,
10 => 10,
5 => 5,
}
TAG = "tier: Red" #customer tag
MESSAGE = "Red tier Bonus" #additional message
customer = Input.cart.customer

if customer
if customer.tags.include?(TAG)
Input.cart.line_items.each do |line_item|
next if line_item.variant.product.gift_card?
quantity, discount = DISCOUNTS_BY_QUANTITY.find do |quantity, _|
line_item.quantity >= quantity
end
next unless discount
message = "Red tier bonus! #{discount}% off when buying at least #{quantity}."
line_item.change_line_price(
line_item.line_price * (Decimal.new(1) - discount.to_d / 100),
message: message
)
end
end
end

Output.cart = Input.cart

£5 off for product for customers in a specific tier

TAG = "tier: Diamond" #customer tag
MESSAGE = "VIP Customer Promotion - £5 off Ocean Blue Shirt" #additional message
customer = Input.cart.customer

if customer
if customer.tags.include?(TAG)
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
next if product.gift_card?
next unless product.id == 1756778135622
line_item.change_line_price(line_item.line_price - Money.new(cents: 500), message: MESSAGE)
end
end
end

Output.cart = Input.cart

If you want to learn more about Shopify Script Editor, please see Shopify documentation here.

Did this answer your question?