Docs
STEP 4

Shopify (headless): Sample code

This chapter contains the full text of example code for the integration. What the SDK needs is the method calls described in each step of the integration steps and in the Reference; you don't need to write the code or split the files the same way as this example. The examples are written in React (19 or later). With other frameworks, you call the same methods and follow the same rules.

The code is split into three pages. 4-1 and 4-2 are split by what the code connects to, and 4-3 has the type definitions.

Files

FilePageStep
lib/checkout-plus.ts4-1Step 1: Load the SDK
components/CheckoutPlusProvider.tsx4-1Step 3: Initialize the SDK
components/CheckoutPlusBanner.tsx4-1Step 4: Show the banner
components/CheckoutButton.tsx4-2Step 5: Replace the checkout button
types/checkout-plus.d.ts4-3Step 1: Load the SDK (for TypeScript)

The code you write for your cart is on the step pages: CartConnector is in Step 2: Implement CartConnector, StoreCheckoutPlus is in Step 3: Initialize the SDK, and leaving Checkout+ product lines out of the cart line list is in Don't show the Checkout+ product in the cart line list.

© Recustomer, Inc.