> 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/show-pre-order-state-on-a-product-page.md). Agents can also search and read this documentation through its [MCP server](https://docs.getpurpledot.com/~gitbook/mcp).

# Show pre-order state on a product page

Label a product or variant from its pre-order state and ship dates.

For the endpoints, see [Public API](https://docs.getpurpledot.com/purple-dot-apis/public-api.md).

## Before you start

* `@purple-dot/browser` is initialized, or you can call the Public API with the store's public API key.

## Steps

1. When the shopper has selected a variant, fetch that variant. When no variant is selected, fetch the product by handle.

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

const variant = await api.fetchVariantsPreorderState(variantId, shopperCountry);
const product = await api.fetchProductsPreorderState(productHandle, shopperCountry);
```

`fetchVariantsPreorderState` accepts the numeric variant id. A response can be `null`.

The second argument is the shopper's country as an ISO 3166 code, such as `GB`. It's optional and needs `@purple-dot/browser` 0.3.0 or later. If your Shopify store uses [location-aware waitlists](https://docs.getpurpledot.com/understanding-purple-dot/inventory-and-virtual-locations.md#location-aware-waitlists), this must be included so that the pre-order state reflects only the stock and waitlists that ship to that country.

2. Use `state`:

| State                | What to show                                                                     |
| -------------------- | -------------------------------------------------------------------------------- |
| `NO_OPEN_WAITLISTS`  | The storefront's normal button                                                   |
| `AVAILABLE_IN_STOCK` | The normal in-stock button. A waitlist exists, and stock sells first             |
| `ON_PREORDER`        | **Pre-order**, `waitlist.display_dispatch_date`, and `<purple-dot-learn-more />` |
| `SOLD_OUT`           | A disabled **Sold out** button                                                   |

3. Fetch again when the selected variant changes.

The HTTP calls are `GET /variants/preorder-state` and `GET /products/preorder-state`, with the country in the `country` query parameter. See the [Public API](https://docs.getpurpledot.com/purple-dot-apis/public-api.md).

## Verify

A variant with a live waitlist and no stock shows **Pre-order** and the ship-date text from `display_dispatch_date`. Changing variant updates the label.

## 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:** [Use the browser SDK](https://docs.getpurpledot.com/e-commerce-platforms/other-and-custom/use-the-browser-sdk.md)
* **Look up:** [Use web components](https://docs.getpurpledot.com/e-commerce-platforms/other-and-custom/use-web-components.md), [Public API](https://docs.getpurpledot.com/purple-dot-apis/public-api.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/show-pre-order-state-on-a-product-page.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.
