What Are Shopify Scripts
Shopify Scripts are small Ruby programs that run on Shopify's servers during the checkout process. They can modify the cart before the customer pays: applying discounts, filtering shipping options, hiding payment methods, or implementing complex promotional logic that standard discount codes cannot handle.
Scripts are exclusively available to Shopify Plus merchants via the Script Editor app.
Script Editor Overview
Install the Script Editor app from the Shopify App Store (it is free for Plus merchants). Scripts are organised by type: Line Item, Shipping, and Payment. Each checkout can run one active script of each type simultaneously.
The editor provides a code interface with Ruby syntax. Shopify provides starter templates for common use cases. You write the logic, test it with sample cart data, and publish it.
Line Item Scripts
Line item scripts modify prices and discounts on individual cart items. Common uses: volume-based discounts (buy 3 get 10% off), tiered pricing for B2B customers (tagged customers get different prices), bundle discounts (buy product A and B together for 15% off), and free gift with purchase logic.
Example: a script that applies a 15% discount to all items in the cart when the total exceeds £150. This is more flexible than a standard automatic discount because you can apply it conditionally based on complex cart logic.
Shipping Scripts
Shipping scripts filter and modify shipping options shown to customers. Uses: hide certain shipping methods for products requiring special handling, show only click-and-collect for specific postcodes, rename shipping options to be more customer-friendly, or sort shipping options in a custom order.
Example: a script that hides standard post as an option when the cart contains a product tagged as "fragile", ensuring fragile items always use tracked services.
Payment Scripts
Payment scripts show or hide payment methods based on cart or customer conditions. Uses: hide pay-later options for high-risk order patterns, show specific payment methods only for B2B customers, or hide cash on delivery for orders above a certain value.
Example: hide Klarna as a payment option when the cart total is below £50, as very small Klarna orders have poor repayment rates and high merchant fees.
Testing Scripts
The Script Editor includes a test functionality where you can input sample cart data and see how the script transforms it. Test with multiple scenarios: empty cart, single item, bulk quantities, mixed product types, different customer tags.
Publish scripts to your development theme and test with real purchases before making them live on your production store.
Scripts vs Functions
Shopify is deprecating Script Editor in favour of Shopify Functions, a more performant and flexible system that runs at the edge rather than on Shopify's Ruby servers. If you are building new checkout customisations, use Shopify Functions.
If you have existing scripts, plan your migration to Functions. The logic is typically rewritable in Shopify Functions using JavaScript or TypeScript, but requires development resource.