Creating and enabling scripts
You write scripts in the Shopify Scripts API. This API is a version of the Ruby programming language, so you need experience in programming with Ruby. Use the Script Editor to create, edit, test, and publish your scripts.
Before you start writing a script, you should review the different types (line item, shipping, and payment) of scripts so that you are aware of the methods that each script type supports. For example, a line item script cannot use shipping methods.
Only one script per script type can be published at one time. For example, you can publish a line items script and a shipping rates script, but you can't publish two line items scripts at the same time.
When you create (or edit) a script, you choose whether it will run in your online store only or in your online store and in the following apps:
- Custom apps that generate checkouts
- Tapcart and Plobal Apps mobile app builders
You can find examples of common scripts in the script templates that are provided in the Script Editor. To view these templates, you need to create a script.
Create a script
To create a script:
Review the Shopify Scripts API for a reference on writing code for scripts.
- Open the Script Editor. The Scripts overview page shows a list of scripts for your store.
- Click Create script to begin creating a new script.
- In the Select script template dialog:
- Choose the type of script that you want to create.
- Choose an example template as a starting point, or choose Blank template to start writing a script from scratch.
- Click Create script to create a script with the type that you have chosen.
- In the Title box, enter a name for the script. Use a descriptive name so you can tell what the script does at a glance.
- Click Code to open the Ruby source code console.
- Enter the code for your script. Use the Shopify Scripts API documentation as a reference.
- Click Run script to run the script.
- When you are finished:
- click Save draft to save an unpublished draft of the script
- click Save and publish to create and publish the script.
After you have written a script, you should test and debug it before you publish it. You can also can update your Liquid template files so that your storefront responds to the changes that your scripts make.
Learn more about: