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.

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.

  1. Open the Script Editor. The Scripts overview page shows a list of scripts for your store.

  2. Click Create script to begin creating a new script.

  3. In the Select script template dialog:

    1. Choose the type of script that you want to create.
    2. Choose an example template as a starting point, or choose Blank template to start writing a script from scratch.
    3. Click Create script to create a script with the type that you have chosen.
  4. 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.

  5. Click Code to open the Ruby source code console.

  6. Enter the code for your script. Use the Shopify Scripts API documentation as a reference.

  7. Click Run script to run the script.

  8. 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.

Next steps

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

Learn more about:

Ready to start selling with Shopify?

Try it free