Shopify
3 Minutes to read

How to create a unique shopping experience with Shopify Scripts

Mads Høegh Kongensgaard

Shopify Tech Lead

Mads has several years of experience with Shopify, and he helps our customers use the platform's many advantages every day - both for B2C and B2B.

You always try to make the experience for your visitors as unique as possible, and that is now possible with Shopify Scripts.

You can program several things in your checkout process, where you can implement custom logic and customize the user experience during your visitors' checkout experience. This app is only available for Shopify Plus subscriptions.

Shopify Scripts are small pieces of code that allow you to create customized experiences for your customers in the shopping cart and and when paying. There are three different types of Shopify Scripts:

Product line scripts. Here you can customize the products that have been added to your visitors' shopping cart. Here you will be able to change the prices and give special discounts on selected products. This script would run every time a product is added, removed, or edited in your customers' shopping cart.

Here are examples of product line scripts:

1. You can e.g. offer customers a discount of DKK 50 on their total purchase if they spend more than DKK 500 on your website. If they spend more, you can always set the discount higher. It's all custom.

2. You can e.g. offer customers a 10 % discount on each hat if they buy 2 hats or more, or a 15 % discount if they buy 5 hats or more.

3. You can e.g. offer customers a 20 % discount on the purchase of a T-shirt, a hat, and a pair of sunglasses.


Delivery scripts. This script will be able to interact with your delivery options. Here you will be able to change different delivery methods and give different discounts on your delivery prices. These scripts would run every time a visitor enters the page with delivery options before payment. 

Here are examples of delivery scripts: 

1. You can e.g. show a specific delivery price for customers in the postal code 7500 Holstebro in Denmark. This price would be hidden from all other locations that do not have that zip code. 

2. You can e.g. hide a specific delivery price for customers in Germany if they buy a T-shirt.

3. You can e.g. offer a 10 % discount on a specific price if the customer has tagged VIP.

Payment scripts. This script will interact with your payment module. Here you will be able to hide, rename, and change the order of your various payment gateways. These scripts will run every time your customers visit the payment method page. Payment scripts do not interact with payment gateways, such as PayPal Express or Apple Pay displayed to your customer before payment

Here are examples of payment scripts:

1. You can e.g. only show a specific gateway if a customer orders from France - the gateway is hidden from addresses in any other country.

2. You can e.g. show a specific gateway if a customer spends DKK 1000 or more, and hide it at other times.

3. You can e.g. only show a specific gateway for customers with the VIP tag - the gateway is hidden from all other customers.

 

Scripts requirements and limitations

Security is important when you need to run various scrips on your website. No matter how many customers you have at any given time in your store, there are therefore som limitations that one must pay special attention to. I have included the 10 most important examples of limitations and things to pay special attention to when using Shopify Scripts.

1. Only one script can be published per script type at a time. You can e.g. publish a script for products and a script for delivery options, but you can not publish two scripts for products at the same time. 

2. You can create up to 200 Shopify Scripts.

3. Scripts for products, scripts for delivery, and scripts for payment do not work with order drafts or payment process for order drafts.

4. Shopify Scripts do not have access to meta-fields.

5. Scripts can access information about whether a discount code is used, the amount of the discount and the type of discount (fixed amount, percentage, or delivery). However, they will not be able to access information on how the discounts are used (specific to shopping cart or product). Scripts also can not access information about the total amount of the order after discount or automatic discounts.

6. Scripts can not add items to the shopping cart or increase the price of an item.

7. Scripts can not increase the cost of delivery.

8. You can create scripts with up to 24.576 characters.

9. When using Shopify Scripts with fast payment process, delivery discounts are applied when your customer chooses an expedited payment method. Therefore, changes in the price of the order are not reflected on the customer's device or in the customer's browser. Customers are shown the original price in their faster payment process, but they are charged the correct price including discount.

10. With a few exceptions, Shopify Scripts are unable to handle input/output. This means that scripts can not execute web requests or database calls, and they can not receive input from a user.

 

Kontakt os nu