> For the complete documentation index, see [llms.txt](https://docs.getpurpledot.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.getpurpledot.com/e-commerce-platforms/other-and-custom/headless-setup-tips.md). Agents can also search and read this documentation through its [MCP server](https://docs.getpurpledot.com/~gitbook/mcp).

# Headless setup tips

Keep pre-order state, line attributes, and checkout in step on a custom storefront.

Worked Shopify examples are [combined checkout](https://docs.getpurpledot.com/e-commerce-platforms/shopify/integrate-with-a-headless-storefront/combined-checkout.md) and [express checkout](https://docs.getpurpledot.com/e-commerce-platforms/shopify/integrate-with-a-headless-storefront/express-checkout.md). The same `@purple-dot/browser` calls apply on another storefront that can run them.

## Before you start

* You know whether the store uses combined cart or express checkout.
* The package is initialized. Combined cart also needs a cart adapter. See [Use the browser SDK](https://docs.getpurpledot.com/e-commerce-platforms/other-and-custom/use-the-browser-sdk.md).

## Steps

1. Refresh pre-order state when the selected variant changes. A product can have one variant on pre-order and another in stock.
2. For combined cart, put `purpleDotAttributes` on the line when the state is `ON_PREORDER`. The helper sets `__releaseId`. It sets `Purple Dot Pre-order` to the ship-date text when the waitlist has no selling plan. Show that attribute in the cart.
3. For an AJAX cart on Shopify, `start` from `@purple-dot/browser/shopify-ajax-interceptors` can add those attributes on cart requests. Other platforms should set the attributes where the line is created.
4. Open checkout only when it applies. Express checkout calls `openExpressCheckout` and does not add the variant to the platform cart. Combined checkout calls `checkout.open`, and passes `{ cartId }` for a Storefront API cart.
5. Call `cartHasPreorderItem` before sending a combined cart to the platform checkout. With no argument it reads the adapter. Pass line items when you already have them. Each item needs `attributes` of `{ key, value }`.

## Verify

An in-stock cart uses your platform checkout. A cart with `__releaseId` opens the Purple Dot checkout. An express pre-order never appears as a platform cart line.

## Troubleshooting

* [The pre-order button is not showing](https://docs.getpurpledot.com/troubleshooting/storefront-and-checkout/pre-order-button-is-not-showing.md)

## Related

* **Concept:** [What you need to build](https://docs.getpurpledot.com/e-commerce-platforms/other-and-custom/what-you-need-to-build.md)
* **Do this:** [Show pre-order state on a product page](https://docs.getpurpledot.com/e-commerce-platforms/other-and-custom/show-pre-order-state-on-a-product-page.md)
* **Look up:** [Use web components](https://docs.getpurpledot.com/e-commerce-platforms/other-and-custom/use-web-components.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.getpurpledot.com/e-commerce-platforms/other-and-custom/headless-setup-tips.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
