Skip to content

Before you integrate

The Headless SDK lets custom Shopify storefronts sell Shipping Protection (SP) and Product Protection (PP). These storefronts are built without a Liquid theme, for example with Hydrogen, Next.js, or Nuxt. Reading this page takes about five minutes. You’ll learn how responsibilities split between the SDK and your storefront, what to prepare, which store settings to confirm with your account manager (AM), and which pages to read next.

AreaThe SDKYour storefront
UIRenders the SP panel, the PP panel, and their modalsRenders product pages, cart page, cart drawer, and checkout buttons
PricingCalculates SP quotes and PP plan prices—
Cart writesWith the default adapter, writes fee lines and protection lines through the Storefront API. With an adapter, uses your endpoints. pp.addToCart drives the main product write, synchronization, and protection in one callAdds main products from the pp.addToCart callback, updates quantities, removes lines, navigates to checkout
State syncCalls your onCartChange callback after an SDK cart write or a confirmed syncCart. The callback reports confirmed facts only and does not signal business successCalls syncCart(cart.id) after modifying the cart

The SDK renders panels and modals, including panel switches and modal buttons, without rewriting your existing buttons. Panels mount inside the configured containers. The SDK mounts modals separately. You render the checkout, add-to-cart, and cart add-protection buttons and call the corresponding SDK method from each click handler, as shown in each scenario guide.

  • The Xcotton Shopify plugin is installed on the store.
  • You have the store’s Shopify Storefront API public access token (used by the default adapter to read and write the cart).
  • The store is configured to run SDK v0.3 (version code 030). These docs and the type definitions apply to v0.3 only. If your store runs v0.2 (024), read Upgrade from v0.2 to v0.3 first.
  • Your pages can supply three values to the SDK at startup: the active market’s country, currency, and language.

Settings your account manager (AM) configures

Section titled “Settings your account manager (AM) configures”

Your account manager (AM) configures the following behaviors in the back office. They cannot be overridden from frontend code. Because they determine which integration code you write, confirm each item before you start:

SettingValuesImpact on your code
SP enabledOn / offWhen off, window.xcotton.sp is undefined. Skip all SP guides
PP enabledOn / offWhen off, window.xcotton.pp is undefined. Skip all PP guides
SP integration modecart, checkout, checkout+Determines how you wire your checkout buttons. See Integration modes
SP panel style and copyWith switch (cart / checkout) / price only (checkout+)Match the panel style to the integration mode: cart / checkout use a switch to express intent, while checkout+ uses two storefront checkout buttons
SP switch default stateOn / offInitial switch state the first time a visitor opens the cart
PP panel theme and copy—No code changes required
Open PP plan modal on add to cartYes / nocanBePopup() decides whether to open a modal when no plan is selected.pp.addToCart() reuses the same check
Show cart add-protection buttonYes / noWhen off, getCartQuotes() returns { enabled: false, quotes: [] }

Subsequent pages use these terms throughout:

TermMeaning
Shipping Protection (SP)Order-level shipping coverage priced for the entire cart. When added, the cart contains one fee line.
Product Protection (PP)Item-level coverage priced per product. When added, a protection line is placed alongside the main product line.
fee lineThe cart line written by SP for the Shipping Protection (SP) charge.
protection lineThe cart line written by PP, linked to a specific main product line.
main product lineThe Storefront API CartLine representing a regular product purchased by the customer.
integration modeControls when the SP fee line is written to the cart: cart, checkout, or checkout+.
panelThe SP or PP UI rendered by the SDK inside a container element you provide.
binding the cartCalling syncCart(cartId) to tell the SDK which cart is active. The same method handles the first bind, cart switches, and same-cart refreshes.
adapterOptional. Replaces the SDK’s default Storefront API client when cart operations go through your own API or BFF.
  1. Quick start (required): load the SDK and render the SP panel on the cart page.
  2. Keep the cart in sync (required): understand how syncCart and onCartChange divide responsibilities. Most integration bugs come from mixing them up.
  3. If SP is enabled: read Integration modes. For checkout or checkout+, continue to Checkout mode or Checkout+ mode.
  4. If PP is enabled: read Add product protection, then Product protection modal and Cart add-protection button as needed.
  5. Advanced and reference: if cart requests go through your own API or BFF, read Use your own cart API. For full method signatures, types, and error messages, see the SDK Reference.