Setting Up Shopify Scripts: How to Create and Manage Custom Scripts in Your Shopify Plus Store

Table of Contents
Big thanks to our contributors those make our blogs possible.

Our growing community of contributors bring their unique insights from around the world to power our blog. 

Introduction

If you’re using Shopify Plus, one of the most powerful features at your disposal is Shopify Scripts—a server-side customization tool that lets you control line-item pricing, discounts, shipping options, and payment methods during checkout. Unlike apps, Scripts run natively on Shopify’s infrastructure, ensuring fast execution and seamless integration.

In this guide, we’ll walk through how to set up, write, and manage custom Shopify Scripts, giving you full control over the checkout experience and enabling advanced promotions tailored to your business.

What Are Shopify Scripts?

Shopify Scripts are small pieces of code written in Ruby that run on Shopify’s servers during checkout. They’re available exclusively on Shopify Plus and are executed before the customer completes their order.

Scripts can modify:

  • Line item prices (e.g., discounts, bundles)
  • Shipping options (e.g., free shipping thresholds)
  • Payment gateways (e.g., hiding certain methods)

Scripts are managed through the Shopify Script Editor, a dedicated app in the Shopify Admin.

Key Use Cases for Shopify Scripts

  • Automatic discounts based on cart quantity or customer tags
  • Tiered or BOGO pricing rules
  • Dynamic shipping rate adjustments
  • Customer group-specific payment method restrictions
  • Complex promotions without requiring discount codes

Step 1: Install the Script Editor App

To begin using Scripts, first install the Script Editor app from your Shopify admin.

How to install:

  1. Go to Apps > Visit Shopify App Store
  2. Search for “Script Editor”
  3. Click Install and grant required permissions

Once installed, you’ll find it under Apps > Script Editor.

Step 2: Understand Script Types

Shopify supports three types of scripts, each affecting a specific part of the checkout:

Script TypeAffectsCommon Use Cases
Line Item ScriptsItems in the cartDiscounts, bundles, tiered pricing
Shipping ScriptsAvailable shipping methodsFree shipping thresholds, method sorting
Payment ScriptsAvailable payment gatewaysGateway restrictions by location/customer

Step 3: Create Your First Script

Example: Line Item Discount Based on Quantity

This script applies a 20% discount when a customer buys 3 or more of a specific product.

rubyCopyEdit# Apply 20% discount when buying 3+ of product X
PRODUCT_ID = 1234567890

Input.cart.line_items.each do |line_item|
  if line_item.variant.product.id == PRODUCT_ID && line_item.quantity >= 3
    line_item.change_line_price(line_item.line_price * 0.8, message: "Bulk discount applied")
  end
end

Output.cart = Input.cart

To implement:

  1. Open Script Editor
  2. Click Create Script
  3. Choose Line Item Script
  4. Use the Ruby editor to enter or modify your script
  5. Click Save and Test

You can test the script using a built-in cart simulator before publishing.

Step 4: Script Management and Deployment

Preview Your Script:

  • Use Test Carts in the editor to simulate different cart conditions
  • Verify that pricing, shipping, or payment options update as expected

Deploy a Script:

  • Once tested, click Publish
  • Only one active script per type (line item, shipping, payment) can run at a time

Tip: To combine functionalities (e.g., multiple discount types), include them in a single script block.

Step 5: Advanced Scripting Techniques

Combine Discounts with Tags

rubyCopyEdit# VIP customers get 10% off
if Input.cart.customer && Input.cart.customer.tags.include?("VIP")
  Input.cart.line_items.each do |line_item|
    line_item.change_line_price(line_item.line_price * 0.9, message: "VIP Discount")
  end
end

Free Shipping on Orders Over $150

rubyCopyEdit# Apply free shipping if subtotal > $150
free_shipping = ShippingRate.new(name: "Free Shipping", price: Money.zero)

if Input.cart.subtotal_price > Money.new(cents: 15000)
  Output.shipping_rates = [free_shipping]
else
  Output.shipping_rates = Input.shipping_rates
end

Limitations to Consider

  • Scripts only run on Shopify’s checkout, not in the cart or on the storefront.
  • They cannot create new products, modify inventory, or interact with external APIs.
  • Scripts are written in Ruby, so JavaScript knowledge won’t transfer directly.
  • Only one script of each type can be active at a time.

For more dynamic control, consider combining Scripts with Shopify Functions or checkout extensions via the Hydrogen/Remix stack.

Conclusion

Shopify Scripts provide unmatched flexibility at the checkout level—especially for Plus merchants who want granular control over pricing, shipping, and payment behavior. With the Script Editor and Ruby-based logic, you can craft tailored experiences that drive higher conversions, reward loyal customers, and streamline operations.

If you’re managing a Shopify Plus store and need custom checkout logic, investing time in mastering Scripts is well worth it. Start small, test often, and build powerful promotional mechanics that apps alone can’t deliver.

Let's connect on TikTok

Join our newsletter to stay updated

Sydney Based Software Solutions Professional who is crafting exceptional systems and applications to solve a diverse range of problems for the past 10 years.

Share the Post

Related Posts