create-cartbase 0.1.8 → 0.1.10
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.
|
@@ -108,6 +108,69 @@ curl -s "$BASE/api/store/regions/reg_doesnotexist$RUN" \
|
|
|
108
108
|
|
|
109
109
|
---
|
|
110
110
|
|
|
111
|
+
## GET /api/store/countries
|
|
112
|
+
|
|
113
|
+
- **Purpose** — the countries a shopper may choose at checkout.
|
|
114
|
+
|
|
115
|
+
**The rule is the platform's, not your storefront's.** The store's own
|
|
116
|
+
Markets decide where it sells, and a store that has decided nothing yet
|
|
117
|
+
sells to the whole world. So this endpoint answers with:
|
|
118
|
+
|
|
119
|
+
- the countries the store's regions declare, when it has declared any
|
|
120
|
+
(`"restricted": true`), or
|
|
121
|
+
- the whole 250-entry ISO catalogue, when it has declared none
|
|
122
|
+
(`"restricted": false`).
|
|
123
|
+
|
|
124
|
+
Either way your code hardcodes no country list and invents no fallback of
|
|
125
|
+
its own. A merchant changes the answer in Admin → Settings → Markets →
|
|
126
|
+
Regions, where a region owns its countries.
|
|
127
|
+
|
|
128
|
+
```jsonc
|
|
129
|
+
// query (all optional)
|
|
130
|
+
{
|
|
131
|
+
"q": "bulg", // case-insensitive substring on the displayed name
|
|
132
|
+
"limit": 300, // 1–300, default 300 — the whole catalogue in one call
|
|
133
|
+
"offset": 0
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- **Response** — ordered by `display_name`, the name a shopper reads.
|
|
138
|
+
|
|
139
|
+
```jsonc
|
|
140
|
+
{
|
|
141
|
+
"countries": [
|
|
142
|
+
{
|
|
143
|
+
"iso_2": "bg", // lowercase alpha-2: the cart address value
|
|
144
|
+
"display_name": "Bulgaria", // what a shopper reads
|
|
145
|
+
"name": "BULGARIA", // the catalogue's uppercase form
|
|
146
|
+
"region_id": "reg_01..." // null when the store has not placed it
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"count": 250,
|
|
150
|
+
"offset": 0,
|
|
151
|
+
"limit": 300,
|
|
152
|
+
"restricted": false
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# every country the store offers, and which of the two lists you received
|
|
158
|
+
curl -s "$BASE/api/store/countries" -H "x-client-id: $CLIENT_ID" \
|
|
159
|
+
| grep -q '"restricted"'
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
- **SDK** — `listCountries(client, query?)` from
|
|
163
|
+
`@cartbase/storefront/api/regions`.
|
|
164
|
+
- **Components** — the checkout address form's country select.
|
|
165
|
+
`useCheckoutOrchestration` CALLS THIS FOR YOU when you do not pass a
|
|
166
|
+
`countries` list, so a new store offers every country with no wiring;
|
|
167
|
+
pass your own list only to override the store's answer. The chosen
|
|
168
|
+
country's flag is drawn by `CountryFlag`
|
|
169
|
+
(`@cartbase/storefront/common/country-flag`).
|
|
170
|
+
- **Settings** — Admin → Settings → Markets → Regions.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
111
174
|
## GET /api/store/currencies
|
|
112
175
|
|
|
113
176
|
- **Purpose** — list the currencies ENABLED on this store (the shared
|
|
@@ -32,8 +32,19 @@ export function CheckoutPageClient({
|
|
|
32
32
|
customer={null}
|
|
33
33
|
availableShippingMethods={shippingOptions}
|
|
34
34
|
availablePaymentMethods={paymentProviders}
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
// NO COUNTRY LIST HERE, on purpose (2026-09-13). This file is the
|
|
36
|
+
// seed for every scaffolded store, and it used to pass
|
|
37
|
+
// `countries={[{iso_2:"bg", display_name:"Bulgaria"}]}` with
|
|
38
|
+
// `countryCode="bg"`, so every store on earth shipped a checkout
|
|
39
|
+
// offering one country, Bulgaria, in a box the shopper could not
|
|
40
|
+
// change. The list belongs to the store, not to this file: omit the
|
|
41
|
+
// prop and the hook reads GET /api/store/countries, which answers
|
|
42
|
+
// with the countries the store's Markets declare, or with the whole
|
|
43
|
+
// world when it has declared none.
|
|
44
|
+
//
|
|
45
|
+
// A single-market store adds `countryCode="xx"` here to preselect
|
|
46
|
+
// its country, and a store that sells to exactly one country gets
|
|
47
|
+
// the read-only field automatically, because its Markets say so.
|
|
37
48
|
// Per-store rule (the documented paymentMethodFilter seam): this
|
|
38
49
|
// reference store checks out offline via its merchant methods only
|
|
39
50
|
// (pp_* kill: method entries carry payment_method_id, processors
|