Build A Checkout UpSell App

In this mini lecture we will walk through the steps needed to build and deploy a Shopify app that extends the buyers experience by suggesting additional products to add to their cart prior to checkout.

Shopify for eCommerce

Shopify is the second most used e-commerce platform worldwide, with 20% of the top 1 million live websites worldwide being powered by Shopify. It's particularly dominant in the United States and several large and well-known brands use Shopify including Nestle, Pepsi, Unilever, Kylie Cosmetics, Vogue, and Gymshark.

Shopify Apps

Shopify apps are built on a variety of Shopify tools to create a great merchant experience. At the time of writing this tutorial there were over 8,000 apps published in the Shopify App Store, not including all of the custom apps built for specific stores.

There is also a high demand for Shopify React Developers which makes the combination of Shopify and React skills particularly valuable.

Creating a Pre-Purchase Product Offer App

This mini lecture is based on Shopify an existing pre-purchase product offers tutorial but also introduces additional tools (which ones? GraphiQL, Theme Editor) and context to help further your understanding of Shopify's tech stack and ecosystem.


⏰ Activity - 5min

Before we do anything let's take a first take a look at what we will be building and how we can manage our app in the Shopify Theme Editor.

Demo the deployed app and adding/positioning the app in the Theme Editor.


What you'll learn

In this tutorial, you'll learn how to do the following tasks:

  • Create a basic checkout UI extension that renders some text in the checkout flow.

  • Run the extension locally and test it on a development store.

  • Show an initial loading state for the products to be offered.

  • Fetch and filter cart lines from the Storefront API, to display to customers.

  • Add a cart line to an order.

  • Deploy your extension code to Shopify.

Additionally you will learn:

  • To install and use the Shopify GraphiQL app within the store Admin
  • Position the app at different extension points in the Checkout Theme Editor
  • Deploy the app on Gadget.dev

Requirements


⏰ Check-in

Confirm everyone has created a free Gadget.dev account and a Shopify Partner account.


Create A New Shopify Store

In order to work with checkout extensions we need to create a development store with checkout extensibility developer preview enabled.

Login to shopify.com/partners and click on Add store button.

Choose Create a store to test and build

Give your store a unique name/url and choose Checkout extensibility from the Developer Preview dropdown.

Now you will be able to open the store's Admin console.

Under Sales channels > Online Store click View your store.

Create a Shopify App

Back in Shopify Partners click on the Apps side navigation link and then click the Create app button.

Assign the app a name and click Create

Once the app is created we will be provided Client crednetials, including the Client ID and Client secret, both of which we will be needed later when creating a new app on Gadget.

Gadget

  1. Login to Gadget.dev
  2. Create a new Gadget app (name must be unique in the gadget.app namespace.)
  3. Click Click to Shopify button

Add your Shopify Client ID and Client Secret keys.

Connect to Shopify.

Choose Product for the scope.

Copy the App URL and Allowed redirection URL from Gadet to our new Shopify app.

Click Save

Open app in VSCode and delete the Web folder and then run:

npm run dev

Here you will be prompted to choose the Partner Organization

And then choose No, connect it to an existing app

Once the previous steps are completed start the app by running:

npm run dev

You will be prompted to install the @shopify/create-app package

Choose node

Assign your app a name.

Once completed you should see the following success message.

Once the previous steps are completed start the app by running:

npm run dev

At this point we can ctrl + c to quit as the app won't respond just yet.

Create a UI extension

Now that the Shopify Cli has successfully created a project its time to generate an extension. This requires providing the following info:

  1. Type of extension
  2. Extension name
  3. What tech will we be building in

Create the extension by running:

npm run shopify app generate extension 

Install the app on your store

Click on the app we just built.

Click the Select store button.

Choose your store.


⏰ Activity - 5min

Provide quick overview of the by reviewing the Sample Code.


Start your local env

Run npm run dev to start the local environment.

This will provide a Preview URl so copy/paste that into a new tab to open the Developer Console.

Now click checkout ui extension to open Shopify Checkout and render the extension. If everything was successful you should see the extension rendered on the top left of the app.

Import Components

Set up the extension point

Fetch products for the offer

Select which products to offer

Set up the logic to display an error banner

Render the components

Deploy the UI Extension

Resources