> 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/shopify/integrate-with-hydrogen/combined-checkout.md). Agents can also search and read this documentation through its [MCP server](https://docs.getpurpledot.com/~gitbook/mcp).

# Set up combined checkout with Hydrogen

Load pre-order state in Hydrogen, attach cart attributes, and open combined checkout.

For install and initialization, see [Integrate with Hydrogen](https://docs.getpurpledot.com/e-commerce-platforms/shopify/integrate-with-hydrogen.md).

## Before you start

* `@purple-dot/browser` initializes with the public API key and `ShopifyStorefrontCart`.
* The product route can read the selected variant id and the product handle.

## Steps

1. On the product route, load both pre-order states. `fetchVariantsPreorderState` accepts the numeric Shopify variant id. Hydrogen merchandise ids are GIDs, so take the variant id from the GID before you call it.

```ts
import * as api from '@purple-dot/browser/api';

const productState = await api.fetchProductsPreorderState(handle);
const variantState = await api.fetchVariantsPreorderState(variantId);
```

Either call can return `null`. When `variantState.state` is `ON_PREORDER`, keep `waitlist.id`, `waitlist.display_dispatch_date`, `waitlist.selling_plan_id`, and `waitlist.compatible_checkouts` with the selected variant. Label the button **Pre-order**, show the ship-date text, and render `<purple-dot-learn-more />`. When the state is `SOLD_OUT`, disable the button.

If the store uses [location-aware waitlists](https://docs.getpurpledot.com/understanding-purple-dot/inventory-and-virtual-locations.md#location-aware-waitlists), pass the shopper's country code as the second argument to either call, such as `fetchVariantsPreorderState(variantId, 'GB')`. See [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).

Use your own product route and add-to-cart component. The package doesn't require specific component names.

2. Pass `purpleDotAttributes` as the cart line attributes. The helper's argument uses `isPreorder`, `releaseId`, `estimatedShipDates`, `sellingPlanId`, and `compatibleCheckouts`.

```ts
import { purpleDotAttributes } from '@purple-dot/browser/cart';

const attributes = purpleDotAttributes({
  isPreorder: variantState?.state === 'ON_PREORDER',
  releaseId: variantState?.waitlist?.id,
  estimatedShipDates: variantState?.waitlist?.display_dispatch_date,
  sellingPlanId: variantState?.waitlist?.selling_plan_id,
  compatibleCheckouts: variantState?.waitlist?.compatible_checkouts,
});
```

In the cart UI, show the line attribute `Purple Dot Pre-order` when it is present.

3. On the cart page, open combined checkout when the cart has a pre-order. Call this from an effect in the cart page, after the cart has loaded. Do not call a hook from inside the render of a child.

```ts
import * as checkout from '@purple-dot/browser/checkout';
import { cartHasPreorderItem } from '@purple-dot/browser/cart';

const hasPreorder = await cartHasPreorderItem(cartLines);
if (hasPreorder) {
  await checkout.open({ cartId: cart.id });
}
```

`cartLines` must be the line items the cart adapter can read. Each line needs an `attributes` array of `{ key, value }`.

4. Render `<purple-dot-self-service />` on the shopper page. Set **Cancel link** under **Settings** > **Email** to that page's `https://` URL. See [Customize shopper emails](https://docs.getpurpledot.com/set-up-and-launch/checkout-and-shopper-experience/customize-shopper-emails.md).

## Verify

The cart line has `__releaseId`. Checkout opens an embedded Purple Dot checkout. A cart with no pre-order still uses Shopify checkout.

## 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:** [Combined cart](https://docs.getpurpledot.com/understanding-purple-dot/choosing-a-checkout-method.md#combined-cart)
* **Do this:** [Integrate with Hydrogen](https://docs.getpurpledot.com/e-commerce-platforms/shopify/integrate-with-hydrogen.md)
* **Look up:** [Set up combined checkout for a headless storefront](https://docs.getpurpledot.com/e-commerce-platforms/shopify/integrate-with-a-headless-storefront/combined-checkout.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/shopify/integrate-with-hydrogen/combined-checkout.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.
