@spree/docs 0.1.131 → 0.1.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-reference/store.yaml +204 -232
- package/dist/developer/core-concepts/channels.md +49 -0
- package/dist/developer/core-concepts/stores.md +11 -2
- package/dist/developer/storefront/nextjs/architecture.md +22 -15
- package/dist/developer/storefront/nextjs/customization.md +8 -82
- package/dist/developer/storefront/nextjs/deployment.md +41 -60
- package/dist/developer/storefront/nextjs/emails.md +86 -0
- package/dist/developer/storefront/nextjs/environment-variables.md +88 -0
- package/dist/developer/storefront/nextjs/multi-region.md +75 -0
- package/dist/developer/storefront/nextjs/quickstart.md +11 -7
- package/dist/developer/storefront/nextjs/testing.md +81 -0
- package/dist/developer/storefront/nextjs/wallet-payments.md +52 -0
- package/dist/developer/storefront/nextjs/wholesale.md +82 -0
- package/package.json +1 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Multi-Region
|
|
3
|
+
description: How the Spree Next.js Storefront serves multiple countries, currencies, and languages from a single deployment via URL segments and edge middleware
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The storefront serves multiple countries, currencies, and languages from a single deployment. Region is encoded in the URL, detected automatically for first-time visitors by middleware, and mapped to a [Spree Market](../../core-concepts/markets.md) — the model that bundles a country, currency, and locale — so every server-side fetch resolves prices and content for the right region.
|
|
7
|
+
|
|
8
|
+
## URL structure
|
|
9
|
+
|
|
10
|
+
Every route is prefixed with a country and locale segment:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
/us/en/products # US market, English
|
|
14
|
+
/de/de/products # German market, German
|
|
15
|
+
/uk/en/products # UK market, English
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The `[country]` and `[locale]` segments are the first two dynamic params of the App Router tree (`src/app/[country]/[locale]/…`). Because region lives in the path, every URL is shareable and independently cacheable, and search engines index each region separately.
|
|
19
|
+
|
|
20
|
+
## The middleware
|
|
21
|
+
|
|
22
|
+
A visitor who lands on a bare path (no region prefix) is redirected to the correct `/{country}/{locale}/…` URL by an edge middleware. It's wired in `src/proxy.ts`:
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { createSpreeMiddleware } from '@/lib/spree/middleware'
|
|
26
|
+
import { getDefaultCountry, getDefaultLocale } from '@/lib/store'
|
|
27
|
+
|
|
28
|
+
export const proxy = createSpreeMiddleware({
|
|
29
|
+
defaultCountry: getDefaultCountry(),
|
|
30
|
+
defaultLocale: getDefaultLocale(),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
export const config = {
|
|
34
|
+
matcher: ['/((?!api/|_next/static|_next/image|favicon.ico|.*\\..*$).*)'],
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`createSpreeMiddleware` (from `src/lib/spree`) does three things:
|
|
39
|
+
|
|
40
|
+
- **Redirects** bare paths to `/{country}/{locale}/…`.
|
|
41
|
+
- **Detects** the visitor's country and locale (see below).
|
|
42
|
+
- **Syncs** `spree_country` and `spree_locale` cookies with the URL segments, so server-side fetches via `getLocaleOptions()` resolve the same market the URL asks for.
|
|
43
|
+
|
|
44
|
+
Requests that already carry a `/{country}/{locale}` prefix pass through untouched — the middleware only refreshes the cookies to match.
|
|
45
|
+
|
|
46
|
+
### Detection chain
|
|
47
|
+
|
|
48
|
+
For a request without a region prefix, each value is resolved from the first source that has it:
|
|
49
|
+
|
|
50
|
+
| Value | Resolution order |
|
|
51
|
+
|-------|------------------|
|
|
52
|
+
| **Country** | `spree_country` cookie → `x-vercel-ip-country` / `cf-ipcountry` geo header → default |
|
|
53
|
+
| **Locale** | `spree_locale` cookie → `Accept-Language` header (primary tag) → default |
|
|
54
|
+
|
|
55
|
+
Geo headers are set by the hosting edge — `x-vercel-ip-country` on Vercel, `cf-ipcountry` behind Cloudflare. On a host that provides neither, detection falls back to `Accept-Language` for locale and the configured default for country. A returning visitor's cookie always wins, so a manual region change sticks.
|
|
56
|
+
|
|
57
|
+
### Configuration
|
|
58
|
+
|
|
59
|
+
`createSpreeMiddleware` accepts:
|
|
60
|
+
|
|
61
|
+
| Option | Description | Default |
|
|
62
|
+
|--------|-------------|---------|
|
|
63
|
+
| `defaultCountry` | Fallback country ISO when nothing else matches | `us` |
|
|
64
|
+
| `defaultLocale` | Fallback locale when nothing else matches | `en` |
|
|
65
|
+
| `staticRoutes` | Path prefixes to skip | `['/_next', '/api', '/dev', '/favicon.ico']` |
|
|
66
|
+
|
|
67
|
+
In the storefront these defaults come from `NEXT_PUBLIC_DEFAULT_COUNTRY` and `NEXT_PUBLIC_DEFAULT_LOCALE` (see [Environment Variables](environment-variables.md)). The `matcher` in `proxy.ts` additionally excludes API routes, Next.js internals, and any path with a file extension, so the middleware only runs on page navigations.
|
|
68
|
+
|
|
69
|
+
## Switching regions
|
|
70
|
+
|
|
71
|
+
The `CountrySwitcher` component (in `src/components/layout/`) lets a visitor change region manually. Selecting a new region navigates to the matching URL prefix; the middleware then updates the `spree_country` / `spree_locale` cookies so the choice persists across future visits.
|
|
72
|
+
|
|
73
|
+
## How region reaches the data layer
|
|
74
|
+
|
|
75
|
+
Region-aware reads don't take a country/locale argument — they call `getLocaleOptions()` from `src/lib/spree`, which reads the `spree_country` / `spree_locale` cookies the middleware keeps in sync with the URL. That value is passed to `@spree/sdk`, which sends it to the Store API so prices, currency, and translated content come back for the right [market](../../core-concepts/markets.md). See [Architecture](architecture.md) for the wider server-first data flow.
|
|
@@ -34,19 +34,19 @@ The [Spree Storefront](https://github.com/spree/storefront) is a production-read
|
|
|
34
34
|
|
|
35
35
|
## Installation
|
|
36
36
|
|
|
37
|
-
###
|
|
37
|
+
### Recommended: create-spree-app
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
The fastest way to get a full project — Spree backend, this Next.js storefront, and the `spree` CLI, wired together — is [`create-spree-app`](../../create-spree-app/quickstart.md):
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
|
-
|
|
43
|
-
cd storefront
|
|
44
|
-
npm install
|
|
42
|
+
npx create-spree-app my-store
|
|
45
43
|
```
|
|
46
44
|
|
|
47
|
-
|
|
45
|
+
The storefront is included by default (pass `--no-storefront` to skip it). It's scaffolded into `apps/storefront/` with its `.env.local` already pointing at the backend, so it boots against real data with no manual key wiring.
|
|
46
|
+
|
|
47
|
+
### Standalone
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
To run the storefront on its own — against an existing Spree backend, or to work on the storefront repo directly — clone it and install:
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
52
|
git clone https://github.com/spree/storefront.git
|
|
@@ -54,6 +54,8 @@ cd storefront
|
|
|
54
54
|
npm install
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
Then follow [Configuration](#configuration) to point it at your Spree API. If you plan to customize and track upstream changes, [fork first](customization.md#tracking-upstream-updates).
|
|
58
|
+
|
|
57
59
|
## Configuration
|
|
58
60
|
|
|
59
61
|
Copy the environment file:
|
|
@@ -81,6 +83,8 @@ npm run dev
|
|
|
81
83
|
|
|
82
84
|
Open [http://localhost:3001](http://localhost:3001) in your browser.
|
|
83
85
|
|
|
86
|
+
> **NOTE:** Testing Apple Pay / Google Pay locally needs a public HTTPS URL. See [Wallet Payments in Development](wallet-payments.md).
|
|
87
|
+
|
|
84
88
|
## Production Build
|
|
85
89
|
|
|
86
90
|
```bash
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Testing
|
|
3
|
+
description: Run the Spree Next.js Storefront's unit tests with Vitest and its end-to-end suite with Playwright against a real Spree backend
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The storefront ships two test layers: fast unit/integration tests with Vitest, and a browser end-to-end suite with Playwright that runs against a real Spree backend booted in Docker.
|
|
7
|
+
|
|
8
|
+
## Unit & integration (Vitest)
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm test # one-shot
|
|
12
|
+
npm run test:watch # watch mode
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## End-to-end (Playwright)
|
|
16
|
+
|
|
17
|
+
The E2E suite drives a browser against a real Spree backend. `npm run e2e:up` boots the backend — Postgres, Redis, and the official `ghcr.io/spree/spree:latest` image from `e2e-backend/docker-compose.yml` — then seeds it and mints an API key through the official [`@spree/cli`](../../cli/quickstart.md) (`spree seed`, `spree sample-data`, `spree api-key create`), installed as a dev dependency. No `create-spree-app` setup is required.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# 1. Export a Stripe test-mode key pair from your own Stripe sandbox.
|
|
21
|
+
# Both keys must belong to the same account — Stripe no longer
|
|
22
|
+
# publishes a working sample secret key, and a mismatched pair makes
|
|
23
|
+
# the checkout payment step fail.
|
|
24
|
+
export STRIPE_PUBLISHABLE_KEY=pk_test_…
|
|
25
|
+
export STRIPE_SECRET_KEY=sk_test_…
|
|
26
|
+
|
|
27
|
+
# 2. Boot Spree + Postgres + Redis, seed sample data, register a Stripe
|
|
28
|
+
# payment gateway, mint a publishable key, and write .env.e2e.
|
|
29
|
+
npm run e2e:up
|
|
30
|
+
|
|
31
|
+
# 3. Run the suite. Playwright boots `next dev` against .env.e2e.
|
|
32
|
+
npm run test:e2e
|
|
33
|
+
|
|
34
|
+
# Optional: interactive UI mode.
|
|
35
|
+
npm run test:e2e:ui
|
|
36
|
+
|
|
37
|
+
# Tear everything down.
|
|
38
|
+
npm run e2e:down
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The checkout test pays with card `4242 4242 4242 4242` through Stripe's [test mode](https://docs.stripe.com/keys). PaymentIntents land in whichever Stripe test account owns the keys you exported.
|
|
42
|
+
|
|
43
|
+
### CI
|
|
44
|
+
|
|
45
|
+
In CI, set `STRIPE_SECRET_KEY` as a repository secret and `STRIPE_PUBLISHABLE_KEY` as a repository variable (**Settings → Secrets and variables → Actions**). The E2E job skips itself on fork PRs, where GitHub never exposes repository secrets.
|
|
46
|
+
|
|
47
|
+
## Testing against a customized backend
|
|
48
|
+
|
|
49
|
+
> **NOTE:** By default the E2E suite runs against the stock official Spree image (`ghcr.io/spree/spree:latest`), so it verifies the storefront against a **vanilla Spree** — not a backend with your own extensions, serializers, or seed data.
|
|
50
|
+
|
|
51
|
+
The E2E stack reads a `SPREE_IMAGE` env var and falls back to the stock image when it's unset. Set it to any image that exposes the Store API on the container's port `3000`, and the suite runs against that backend instead.
|
|
52
|
+
|
|
53
|
+
### Your own Spree image
|
|
54
|
+
|
|
55
|
+
If you already publish a customized Spree image:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
SPREE_IMAGE=ghcr.io/your-org/your-spree:latest npm run e2e:up
|
|
59
|
+
npm run test:e2e
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### A `create-spree-app` project's backend
|
|
63
|
+
|
|
64
|
+
A project scaffolded with [`create-spree-app`](../../create-spree-app/quickstart.md) has its customizable Spree in `backend/` (built from `backend/Dockerfile`) and this storefront in `apps/storefront/`. Build that backend into a local image and point the suite at it — this is what tests the storefront against the **exact Spree you deploy**, extensions and all:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# From the project root — build the customized backend image
|
|
68
|
+
docker build -t project-spree:e2e ./backend
|
|
69
|
+
|
|
70
|
+
# From apps/storefront — run E2E against it
|
|
71
|
+
cd apps/storefront
|
|
72
|
+
SPREE_IMAGE=project-spree:e2e npm run e2e:up
|
|
73
|
+
npm run test:e2e
|
|
74
|
+
npm run e2e:down
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
> **NOTE:** New `create-spree-app` projects wire this into the generated storefront CI workflow automatically — the workflow builds `backend/Dockerfile` and runs the storefront E2E against that image rather than stock Spree.
|
|
78
|
+
|
|
79
|
+
### Interactive / manual
|
|
80
|
+
|
|
81
|
+
To click through the storefront against a running backend (no E2E harness), point it there directly: set `SPREE_API_URL` and `SPREE_PUBLISHABLE_KEY` in `.env.local` (see [Environment Variables](environment-variables.md)) and run `npm run dev`.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Wallet Payments in Development
|
|
3
|
+
description: Test Apple Pay and Google Pay against a local Spree Next.js Storefront using a public HTTPS URL
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Apple Pay and Google Pay require HTTPS **and a publicly-reachable URL** — Stripe verifies the payment method domain from the internet, so `localhost` and locally-trusted certificates (e.g. `mkcert` + `lvh.me`) won't pass domain verification. The simplest way to expose your local storefront with a valid public HTTPS URL is [Cloudflare Tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/).
|
|
7
|
+
|
|
8
|
+
## Setup
|
|
9
|
+
|
|
10
|
+
1. Install `cloudflared`:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
brew install cloudflared
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
2. Start the dev server normally (HTTP on port 3001):
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm run dev
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
3. In a second terminal, expose it through a quick tunnel:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cloudflared tunnel --url http://localhost:3001
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The output will contain a URL like `https://<random-words>.trycloudflare.com`.
|
|
29
|
+
|
|
30
|
+
4. Register that URL in your [Stripe Payment method domains](https://dashboard.stripe.com/settings/payment_methods/domains).
|
|
31
|
+
|
|
32
|
+
5. Open the tunnel URL in your browser and test the Express Checkout buttons in the cart.
|
|
33
|
+
|
|
34
|
+
## Stable tunnel URLs
|
|
35
|
+
|
|
36
|
+
`next.config.ts` already allows `*.trycloudflare.com` via `allowedDevOrigins`, so quick tunnels work out of the box. Every time you restart `cloudflared tunnel --url ...` you get a new random subdomain — if you need a stable URL (to avoid re-registering in Stripe on each run), set up a [named tunnel](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/do-more-with-tunnels/trycloudflare/#using-named-tunnels) on your own domain.
|
|
37
|
+
|
|
38
|
+
## The Spree backend must also be publicly reachable
|
|
39
|
+
|
|
40
|
+
The storefront's server-side fetches go to `SPREE_API_URL`, but image URLs and a few other backend-served paths (e.g. the Apple Pay domain-verification file under `/.well-known/apple-developer-merchantid-domain-association`) are fetched by the browser directly and must resolve from the public internet.
|
|
41
|
+
|
|
42
|
+
Point `SPREE_API_URL` at a hosted Spree (e.g. `*.spree.sh`, `*.vendo.dev`, your own staging) or expose your local Spree with another tunnel:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
cloudflared tunnel --url http://localhost:3000
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
When tunneling a local Rails app, allow the tunnel host in the backend's `.env`:
|
|
49
|
+
|
|
50
|
+
```env
|
|
51
|
+
RAILS_DEVELOPMENT_HOSTS=.trycloudflare.com
|
|
52
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Wholesale Portal
|
|
3
|
+
description: The opt-in B2B wholesale surface and how channel-backed surfaces work
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## What the Wholesale Portal Is
|
|
7
|
+
|
|
8
|
+
The storefront ships an optional **wholesale portal** at `/wholesale` — a gated B2B surface for approved trade buyers. It runs on a separate Spree sales channel but shares the same storefront app and Spree backend as the public direct-to-consumer (DTC) store, so a single deployment serves both audiences: the open catalog for shoppers and a login-gated trade catalog with volume pricing for wholesale buyers.
|
|
9
|
+
|
|
10
|
+
The portal is an **opt-in addon**. It is off by default; a DTC-only storefront never renders any wholesale UI.
|
|
11
|
+
|
|
12
|
+
> **NOTE:** The wholesale portal is a **reference implementation**, not a fixed feature. It demonstrates one shape — a gated B2B surface running *alongside* an open DTC store — but the same building blocks (channels, [surfaces](#surfaces-and-channel-switching), and [access gating](#gating-modes)) support the whole spectrum. You can invert the default and make the storefront closed or limited: gate the *primary* DTC channel with `login_required` or `prices_hidden` for a members-only or invite-only shop, drop the public catalog entirely and ship a login-first B2B storefront, or run several gated channels with no open surface at all. Treat this page as a worked example to adapt, not a prescription — the storefront is yours to reshape.
|
|
13
|
+
|
|
14
|
+
## Surfaces and Channel Switching
|
|
15
|
+
|
|
16
|
+
A **surface** is a distinct sales context backed by its own Spree [channel](../../core-concepts/channels.md). The storefront models two out of the box — `dtc` (the public storefront) and `wholesale` (the trade portal) — but the mechanism is general: any channel on your backend can back its own surface.
|
|
17
|
+
|
|
18
|
+
The surface selects which SDK client a request goes through. A channel-bound client sends the channel code on every request via the `X-Spree-Channel` header, and the Store API [resolves the request against that channel](../../core-concepts/channels.md#resolution-at-request-time) — its catalog, pricing, and access rules. In the SDK this is the `channel` client option:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { createClient } from '@spree/sdk'
|
|
22
|
+
|
|
23
|
+
const wholesaleClient = createClient({
|
|
24
|
+
baseUrl: process.env.SPREE_API_URL,
|
|
25
|
+
publishableKey: process.env.SPREE_PUBLISHABLE_KEY,
|
|
26
|
+
channel: 'wholesale', // sent as X-Spree-Channel on every request
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Alternatively, a **channel-bound publishable key** carries the channel server-side: when a key is scoped to a channel on the backend, the API assigns that channel to the request without needing the header. Either path works; the header is the simplest and is what the storefront uses by default.
|
|
31
|
+
|
|
32
|
+
Because each surface has its own client, cart cookies, and cache keys, a customer can hold an open DTC cart and an open wholesale cart at the same time without them mixing. The customer session (JWT) is shared — it's the same person signing in — so only the cart splits, never the auth.
|
|
33
|
+
|
|
34
|
+
To add your own channel-backed surface, follow the same pattern: create the channel on the backend, add a client bound to its code, and thread the surface through the routes that should target it.
|
|
35
|
+
|
|
36
|
+
## Enabling Wholesale
|
|
37
|
+
|
|
38
|
+
Wholesale turns on through a single environment variable:
|
|
39
|
+
|
|
40
|
+
- **`SPREE_WHOLESALE_CHANNEL`** — the enable switch. Set it to the code of a gated channel on your backend (e.g. `wholesale`). There is **no default**: when it is unset, the storefront runs DTC-only — the wholesale nav link, footer link, and homepage section are hidden, and every `/wholesale` route returns 404.
|
|
41
|
+
- **`SPREE_WHOLESALE_PUBLISHABLE_KEY`** — optional. The channel header alone selects the channel, so this falls back to `SPREE_PUBLISHABLE_KEY`. Set it only to bind a channel-scoped publishable key.
|
|
42
|
+
|
|
43
|
+
The backend must have a [channel](../../core-concepts/channels.md) whose code matches `SPREE_WHOLESALE_CHANNEL`. Its [`storefront_access`](../../core-concepts/channels.md#storefront-access-gating) posture decides how much a guest can see — the portal supports both `login_required` (guests are walled off entirely) and `prices_hidden` (guests browse the catalog but not prices). See [Gating Modes](#gating-modes) below. Spree installs seed a `login_required` wholesale channel by default; switching to `prices_hidden` is a single flag on that same channel — no new channel or seed data.
|
|
44
|
+
|
|
45
|
+
## How Gating Works End to End
|
|
46
|
+
|
|
47
|
+
Two independent checks gate the portal — one at the **channel** (how much of the catalog a guest may see), one at the **customer** (whether a buyer may transact at trade pricing). The channel check is set by the channel's [gating mode](#gating-modes); the customer check is always the same.
|
|
48
|
+
|
|
49
|
+
**Channel access** is enforced by the Store API, not the storefront — the storefront can't loosen it. Depending on the channel's `storefront_access` posture, a guest is either rejected outright (`login_required`) or served the catalog with money fields returned as `null` (`prices_hidden`). This is a general channel feature; see [Channels → Storefront Access Gating](../../core-concepts/channels.md#storefront-access-gating) for how it's resolved and enforced.
|
|
50
|
+
|
|
51
|
+
**Buyer approval.** Being logged in isn't enough; a buyer must be *approved*. Approval is membership in the **Wholesale** [customer group](../../core-concepts/pricing.md#customer-group-rule) — an admin adds an applicant to the group to approve them. The storefront reads `customer_groups` on `customers/me` and branches accordingly:
|
|
52
|
+
|
|
53
|
+
- **Guest** — sees the sign-in / apply wall (`login_required`), or the read-only catalog with sign-in-for-pricing prompts (`prices_hidden`).
|
|
54
|
+
- **Signed in, not in the group** — sees an application-pending state. Signing in never skips approval: an authenticated but unapproved buyer cannot transact under either mode.
|
|
55
|
+
- **Signed in and in the group** — gets the full portal: trade catalog, quick order, and the wholesale cart.
|
|
56
|
+
|
|
57
|
+
**Trade pricing** is unlocked by volume. The seeded model grants a trade price once a line reaches a minimum quantity of the same item (10 or more per item in the sample data). The applicable volume rule lives on a backend [Price List](../../core-concepts/pricing.md#price-lists); the storefront surfaces the trade price the API returns for a qualifying quantity.
|
|
58
|
+
|
|
59
|
+
## Gating Modes
|
|
60
|
+
|
|
61
|
+
A channel's `storefront_access` posture is one of three values. The wholesale portal supports the two gated modes; the third describes a fully public channel like DTC.
|
|
62
|
+
|
|
63
|
+
| Mode | Guest sees catalog | Guest sees prices | Guest can order |
|
|
64
|
+
|---|---|---|---|
|
|
65
|
+
| `login_required` | No — hard `401`, sign-in wall | No | No |
|
|
66
|
+
| `prices_hidden` | Yes — read-only | No — "sign in for pricing" | No — "sign in to order" |
|
|
67
|
+
| `public` | Yes | Yes | Yes (subject to guest checkout) |
|
|
68
|
+
|
|
69
|
+
**`login_required`** is the strictest posture and the seeded default. The Store API rejects any unauthenticated request to the channel with `401`, so a guest can't read wholesale catalog or pricing at all. The storefront shows the sign-in / apply wall in place of every gated page.
|
|
70
|
+
|
|
71
|
+
**`prices_hidden`** opens the catalog to guests while keeping pricing private. The channel doesn't reject unauthenticated requests, but the API serializes every money field as `null` for a guest. In the portal, a guest browses the catalog and product pages read-only: each price renders a **"sign in for pricing"** prompt, and add-to-cart becomes **"sign in to order."** Ordering surfaces (cart, quick order) still require sign-in — a guest is redirected to the sign-in flow rather than shown an empty wholesale cart. Approval is unchanged: signing in reveals list prices, and joining the Wholesale group unlocks trade pricing. This mode suits a trade catalog you want discoverable (for SEO or lead generation) without exposing negotiated pricing.
|
|
72
|
+
|
|
73
|
+
**`public`** is an ungated channel — the posture the DTC store runs on. It's listed here for completeness; a wholesale channel would not normally use it.
|
|
74
|
+
|
|
75
|
+
Switching a wholesale channel between the two supported modes is a single change to [`storefront_access`](../../core-concepts/channels.md#storefront-access-gating) on the backend — set on the channel, or inherited from the [store's default](../../core-concepts/stores.md#storefront-access-defaults). Nothing in the storefront needs redeploying — the portal reads the channel's posture at request time and adapts. Login and signup always run through the same approval flow regardless of mode.
|
|
76
|
+
|
|
77
|
+
## Related Documentation
|
|
78
|
+
|
|
79
|
+
- [Channels](../../core-concepts/channels.md) — The sales channel that backs the wholesale surface, and the general [Storefront Access Gating](../../core-concepts/channels.md#storefront-access-gating) mechanism the portal builds on
|
|
80
|
+
- [Stores](../../core-concepts/stores.md) — Store-level [defaults](../../core-concepts/stores.md#storefront-access-defaults) that channels inherit
|
|
81
|
+
- [Pricing](../../core-concepts/pricing.md) — [Price Lists](../../core-concepts/pricing.md#price-lists) and the [Customer Group Rule](../../core-concepts/pricing.md#customer-group-rule) behind approval and trade pricing
|
|
82
|
+
- [Store SDK: Configuration](../../sdk/configuration.md) — `setChannel` and the channel client option used to bind a surface
|