Building a shipping script

In this tutorial, you’ll learn how to create a basic example of a shipping script.

Step 1: Create the script

In the Shopify CLI enter:

Start by replacing the contents of your shipping script src/script.ts with the code below. shippingMethodsHandler runs when a buyer reaches the shipping page at checkout and all shipping rates are returned. The results of this function are the sort order, shipping methods to remove, or shipping methods to rename.

Step 2: Push script to Shopify

Because scripts are hosted on Shopify, you'll need to push the script to Shopify and associate it with an app the first time.

In Shopify CLI enter:

Step 3: Enable in your store

By default scripts are available to be used on a store with the app installed, but are not enabled. In order to alter the behavior of checkout you must enable it.

In Shopify CLI enter:

Step 4: Test the script

Place a test order in your dev store, and go through the checkout steps. The first shipping rate should not show at the shipping step.

Next steps