create-cartbase 0.1.1 → 0.1.2
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/package.json +1 -1
- package/template/app/docs/BUILD-A-STOREFRONT.md +1 -1
- package/template/app/docs/README.md +1 -1
- package/template/app/docs/auth.md +1 -1
- package/template/app/docs/carts.md +3 -3
- package/template/app/docs/categories.md +1 -1
- package/template/app/docs/checkout.md +125 -74
- package/template/app/docs/collections.md +1 -1
- package/template/app/docs/components.md +53 -55
- package/template/app/docs/consent.md +1 -1
- package/template/app/docs/content.md +1 -1
- package/template/app/docs/customers.md +1 -1
- package/template/app/docs/deploy.md +1 -1
- package/template/app/docs/gift-cards.md +1 -1
- package/template/app/docs/integrations.md +1 -1
- package/template/app/docs/menus.md +1 -1
- package/template/app/docs/metaobjects.md +1 -1
- package/template/app/docs/orders.md +1 -1
- package/template/app/docs/platform.md +1 -1
- package/template/app/docs/products.md +1 -1
- package/template/app/docs/redirects.md +1 -1
- package/template/app/docs/regions.md +1 -1
- package/template/app/docs/reviews.md +1 -1
- package/template/app/docs/search.md +1 -1
- package/template/app/docs/subscriptions.md +1 -1
- package/template/app/docs/variables.md +315 -0
- package/template/app/next-env.d.ts +6 -0
- package/template/app/package.json +1 -1
- package/template/app/smoke.mjs +1 -1
- package/template/app/src/app/checkout/checkout-page-client.tsx +26 -10
- package/template/app/src/app/checkout/mypos-demo-tab.tsx +101 -0
- package/template/app/src/app/checkout/page.tsx +48 -51
- package/template/app/src/app/order/[id]/confirmed/page.tsx +5 -4
- package/template/app/tsconfig.tsbuildinfo +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Components
|
|
1
|
+
# Components
|
|
2
2
|
|
|
3
3
|
The component layer of `@cartbase/storefront`: what each family ships, the SDK
|
|
4
4
|
calls it requires, the admin settings that change its behavior, and its mount
|
|
@@ -20,8 +20,7 @@ app's CSS; no component hardcodes a color.
|
|
|
20
20
|
|
|
21
21
|
---
|
|
22
22
|
|
|
23
|
-
## Family: tracking (`@cartbase/storefront/tracking/*`)
|
|
24
|
-
|
|
23
|
+
## Family: tracking (`@cartbase/storefront/tracking/*`)
|
|
25
24
|
Meta Pixel + GA4 + Rybbit + Consent Mode v2. The Cartbase split of duties:
|
|
26
25
|
**this package fires client events and writes attribution; server-side CAPI /
|
|
27
26
|
GA4 Measurement Protocol sending is Cartbase-backend-owned** (the
|
|
@@ -154,8 +153,7 @@ Meta side) and `gtag('set','user_data',…)`. Call alongside
|
|
|
154
153
|
|
|
155
154
|
---
|
|
156
155
|
|
|
157
|
-
## Family: primitives (`@cartbase/storefront/primitives/*`)
|
|
158
|
-
|
|
156
|
+
## Family: primitives (`@cartbase/storefront/primitives/*`)
|
|
159
157
|
Generic shadcn-style building blocks. No SDK calls, no admin settings —
|
|
160
158
|
pure UI over the theme tokens.
|
|
161
159
|
|
|
@@ -172,8 +170,7 @@ pure UI over the theme tokens.
|
|
|
172
170
|
|
|
173
171
|
---
|
|
174
172
|
|
|
175
|
-
## Family: lib (`@cartbase/storefront/lib/*`)
|
|
176
|
-
|
|
173
|
+
## Family: lib (`@cartbase/storefront/lib/*`)
|
|
177
174
|
Pure helpers — no React except `dual-price`, no fetches. The SDK never
|
|
178
175
|
invents server truths: prices/totals arrive computed from the API
|
|
179
176
|
(`variant.calculated_price`, `cart.total`); these helpers only select and
|
|
@@ -204,11 +201,14 @@ format.
|
|
|
204
201
|
- `lib/sort-products` — client-side re-sort of a fetched page
|
|
205
202
|
(`price_asc|price_desc|created_at`); the API's `order` param stays the
|
|
206
203
|
authority for paginated listings.
|
|
207
|
-
- `lib/payment-constants` — `isStripeLike` / `isPaypal`
|
|
208
|
-
`paymentInfoMap`.
|
|
209
|
-
(
|
|
210
|
-
`
|
|
211
|
-
|
|
204
|
+
- `lib/payment-constants` — `isStripeLike` / `isPaypal` +
|
|
205
|
+
`paymentInfoMap`. Two tender shapes since the pp_* kill: a processor
|
|
206
|
+
`provider_id` (`pp_stripe` exact, code truth
|
|
207
|
+
`src/lib/stripe/providers.ts`, plus legacy Medusa-era prefixes as
|
|
208
|
+
fallbacks) or a merchant METHOD rendered by its snapshot NAME — a
|
|
209
|
+
method never has a provider id to bucket. Affected by: connected
|
|
210
|
+
processors + enabled methods + checkout rules (which entries ever
|
|
211
|
+
reach the client).
|
|
212
212
|
- `lib/store-api-error` — `storeApiError(err)`: display-boundary normalizer
|
|
213
213
|
(capitalized message + terminal period).
|
|
214
214
|
Catch `StoreApiError` directly instead when branching on `status`/`code`.
|
|
@@ -217,8 +217,7 @@ format.
|
|
|
217
217
|
|
|
218
218
|
---
|
|
219
219
|
|
|
220
|
-
## Family: checkout (`@cartbase/storefront/checkout/*`)
|
|
221
|
-
|
|
220
|
+
## Family: checkout (`@cartbase/storefront/checkout/*`)
|
|
222
221
|
The full checkout page family, production-proven (deferred-
|
|
223
222
|
intent architecture — no payment session exists until Buy click) onto the
|
|
224
223
|
Cartbase orchestration endpoints. The flow every component serves
|
|
@@ -227,7 +226,7 @@ Cartbase orchestration endpoints. The flow every component serves
|
|
|
227
226
|
```
|
|
228
227
|
listShippingOptions(cart_id) + listPaymentProviders(cart_id) (render pickers)
|
|
229
228
|
→ Buy click → prepareCheckout (ONE atomic, compensated call)
|
|
230
|
-
→ pp_stripe: stripe.confirmPayment(client_secret) |
|
|
229
|
+
→ pp_stripe: stripe.confirmPayment(client_secret) | merchant method: skip
|
|
231
230
|
→ completeCart → navigate to the confirmed page
|
|
232
231
|
```
|
|
233
232
|
|
|
@@ -264,21 +263,24 @@ code-first through the error-copy maps, never raw API strings.
|
|
|
264
263
|
call REACTIVELY from Elements `loaderror` only), `carts.completeCart`.
|
|
265
264
|
- **Props contract** — `{client, cart, customer, availableShippingMethods,
|
|
266
265
|
availablePaymentMethods, countryCode?, countries?, paymentMethodFilter?,
|
|
267
|
-
|
|
266
|
+
orderConfirmedPath?, onOrderPlaced?,
|
|
268
267
|
resolveTrackingMetadata?, logError?}`. `countries` is caller-supplied
|
|
269
|
-
(Cartbase regions embed NO countries array).
|
|
270
|
-
|
|
271
|
-
`logError` replaces the legacy log writers
|
|
272
|
-
points preserved). Returns the full orchestration
|
|
273
|
-
(`performBuyClick`, `optimisticTotal(Cents)`, `deliveryReady`, …).
|
|
268
|
+
(Cartbase regions embed NO countries array). Fee prediction is never
|
|
269
|
+
hardcoded: each method LISTING entry carries its own
|
|
270
|
+
`fee_amount`/`fee_label`. `logError` replaces the legacy log writers
|
|
271
|
+
(all production log points preserved). Returns the full orchestration
|
|
272
|
+
surface (`performBuyClick`, `optimisticTotal(Cents)`, `deliveryReady`, …).
|
|
274
273
|
- **Cartbase specifics** — zero-remainder gift path: `prepareCheckout`
|
|
275
|
-
returning `client_secret:null` + `provider_id:null`
|
|
276
|
-
completes on the gift session
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
`
|
|
274
|
+
returning `client_secret:null` + `provider_id:null` +
|
|
275
|
+
`payment_method_id:null` SKIPS Stripe and completes on the gift session
|
|
276
|
+
([gift-cards.md](gift-cards.md)). Processors are `pp_stripe` exactly;
|
|
277
|
+
merchant methods list as `{payment_method_id, name, kind, instructions,
|
|
278
|
+
fee_amount, fee_label}` entries — the COD-kind method wins the offline
|
|
279
|
+
tab, else the first manual method. The charged fee reads the cart-level
|
|
280
|
+
`payment_method_fee_total` decoration.
|
|
280
281
|
- **Settings** — checkout rules (filter the listings + complete guard),
|
|
281
|
-
|
|
282
|
+
the methods' own fee configuration (Payments settings), Stripe
|
|
283
|
+
credentials, gift cards, `accounts_mode`.
|
|
282
284
|
|
|
283
285
|
### `<CheckoutClient />` — `checkout/checkout-client`
|
|
284
286
|
|
|
@@ -383,11 +385,11 @@ code-first through the error-copy maps, never raw API strings.
|
|
|
383
385
|
badge. `LineItemCard` is the standalone card variant.
|
|
384
386
|
- **SDK calls** — `carts.updateLineItem` (quantity); child widgets below.
|
|
385
387
|
Totals are rendered STRAIGHT from the cart decoration: `item_total`,
|
|
386
|
-
`shipping_total`, `
|
|
388
|
+
`shipping_total`, `payment_method_fee_total`/`payment_method_fee_label`, `discount_total`,
|
|
387
389
|
`tax_total`, `total`, `gift_card_total`, `gift_card_remainder`.
|
|
388
390
|
- **Props contract** — `{client, cart, optimisticShippingCost,
|
|
389
391
|
onOptimisticShippingClear?, optimisticCodFee?, onOptimisticCodFeeClear?,
|
|
390
|
-
|
|
392
|
+
methodFeeLabel?, showGiftCards?, onCartChange?}`. Optimistic values clear
|
|
391
393
|
automatically once the server cart catches up.
|
|
392
394
|
- **Settings** — COD integration (fee row), gift cards, promotions.
|
|
393
395
|
|
|
@@ -445,8 +447,7 @@ extra modules beyond the per-file exports, imported from
|
|
|
445
447
|
|
|
446
448
|
---
|
|
447
449
|
|
|
448
|
-
## Family: cart-drawer (`@cartbase/storefront/cart-drawer/*`)
|
|
449
|
-
|
|
450
|
+
## Family: cart-drawer (`@cartbase/storefront/cart-drawer/*`)
|
|
450
451
|
Sliding cart UI, production-proven layout. All
|
|
451
452
|
components are `"use client"`. Money is EUR decimal major units everywhere
|
|
452
453
|
(cart totals are SERVER truth from the decorated cart — components render,
|
|
@@ -570,8 +571,8 @@ Domain doc for every call: [carts.md](carts.md); gift-card tender:
|
|
|
570
571
|
- **Purpose** — full totals breakdown rendered EXACTLY from the decorated
|
|
571
572
|
cart: `subtotal`, `discount_total` (>0, negated for display),
|
|
572
573
|
`shipping_total` (once a shipping method is set; 0 renders FREE; before
|
|
573
|
-
that "calculated at checkout"), `tax_total` (>0), `
|
|
574
|
-
labeled by the server's `
|
|
574
|
+
that "calculated at checkout"), `tax_total` (>0), `payment_method_fee_total` (>0,
|
|
575
|
+
labeled by the server's `payment_method_fee_label`), `total`, then one row per
|
|
575
576
|
applied gift card (masked `last4`, negated; a depleted card stays listed
|
|
576
577
|
at 0) and `gift_card_remainder` — what the remainder provider charges.
|
|
577
578
|
Row selection is the pure `selectSummaryRows(cart)` (unit-tested).
|
|
@@ -609,8 +610,7 @@ Domain doc for every call: [carts.md](carts.md); gift-card tender:
|
|
|
609
610
|
|
|
610
611
|
---
|
|
611
612
|
|
|
612
|
-
## Family: products (`@cartbase/storefront/products/*`)
|
|
613
|
-
|
|
613
|
+
## Family: products (`@cartbase/storefront/products/*`)
|
|
614
614
|
The PDP + product-card family, production-proven. All prices
|
|
615
615
|
render the SERVER-computed `variant.calculated_price` via
|
|
616
616
|
`lib/get-product-price` (Cartbase's flat `price_list_type` wire shape) — no
|
|
@@ -754,8 +754,7 @@ with a legacy flat-row fallback. Unit-tested
|
|
|
754
754
|
`ProductLabelsProvider` for i18n; `addToCart`/`openCart` seams as on
|
|
755
755
|
`ProductActions`.
|
|
756
756
|
|
|
757
|
-
## Family: store (`@cartbase/storefront/store/*`)
|
|
758
|
-
|
|
757
|
+
## Family: store (`@cartbase/storefront/store/*`)
|
|
759
758
|
The listing family: paginated grids, sort, collection/category/search
|
|
760
759
|
templates. Sorting discipline: the API's `order` param is the authority for
|
|
761
760
|
paginated listings; client-side re-sort (`lib/sort-products`) exists ONLY
|
|
@@ -859,8 +858,7 @@ search UIs (chips, drawers) that want the same URL contract.
|
|
|
859
858
|
|
|
860
859
|
---
|
|
861
860
|
|
|
862
|
-
## Family: order (`@cartbase/storefront/order/*`)
|
|
863
|
-
|
|
861
|
+
## Family: order (`@cartbase/storefront/order/*`)
|
|
864
862
|
Order confirmation + account order views, production-proven. Some
|
|
865
863
|
platforms ship ONE `StoreOrder` object carrying computed line
|
|
866
864
|
totals, order totals, shipping methods and payments; Cartbase splits those
|
|
@@ -894,7 +892,7 @@ component also takes a `labels` prop pick.
|
|
|
894
892
|
rybbit, deduped by `order.display_id`) is APP-OWNED: fire it from the
|
|
895
893
|
confirmation route exactly once per order per the tracking family's
|
|
896
894
|
dedupe contract — the template deliberately does NOT fire it.
|
|
897
|
-
- **Settings** — COD settings (fee row presence + `
|
|
895
|
+
- **Settings** — COD settings (fee row presence + `payment_method_fee_label`),
|
|
898
896
|
checkout rules (which provider ids appear), store locales (labels pack).
|
|
899
897
|
|
|
900
898
|
### `<OrderConfirmationHeader order />` — `order/order-confirmation-header`
|
|
@@ -917,19 +915,19 @@ component also takes a `labels` prop pick.
|
|
|
917
915
|
COD fees are never line items, so on pure Cartbase data the filter is a
|
|
918
916
|
no-op safety net. Newest-first sort by `createdAt` when present.
|
|
919
917
|
|
|
920
|
-
### `<OrderTotals totals currencyCode items?
|
|
918
|
+
### `<OrderTotals totals currencyCode items? methodFeeLabel? />` — `order/order-totals`
|
|
921
919
|
|
|
922
920
|
- **Purpose** — the money breakdown: Subtotal / Shipping (FREE badge at
|
|
923
921
|
0) / COD fee / Discount (negated) / Tax / Total, all via `DualPrice`.
|
|
924
922
|
- **Data seam** — `OrderTotalsSource` (the decorated cart satisfies it:
|
|
925
923
|
`item_subtotal`, `shipping_subtotal`, `discount_total`, `tax_total`,
|
|
926
|
-
`total`, `
|
|
924
|
+
`total`, `payment_method_fee_total`, `payment_method_fee_label`); the summary snapshot adapts
|
|
927
925
|
via `orderTotalsFromSummary`. Row policy is the pure, unit-tested
|
|
928
|
-
`selectOrderTotalsRows`: native `
|
|
926
|
+
`selectOrderTotalsRows`: native `payment_method_fee_total` wins over a legacy fee
|
|
929
927
|
LINE; a legacy fee line's net is subtracted from the visible subtotal
|
|
930
|
-
(v2.3.1 production fix); COD label preference `
|
|
931
|
-
server `
|
|
932
|
-
- **Settings** — COD settings (`
|
|
928
|
+
(v2.3.1 production fix); COD label preference `methodFeeLabel` prop →
|
|
929
|
+
server `payment_method_fee_label` → fee-line title → `labels.paymentMethodFee`.
|
|
930
|
+
- **Settings** — COD settings (`payment_method_fee_total`/`payment_method_fee_label`),
|
|
933
931
|
promotions (discount row).
|
|
934
932
|
|
|
935
933
|
### `<OrderAddressCard order />` — `order/order-address-card`
|
|
@@ -954,11 +952,13 @@ component also takes a `labels` prop pick.
|
|
|
954
952
|
|
|
955
953
|
### `<OrderPaymentCard providerId cardLast4? />` — `order/order-payment-card`
|
|
956
954
|
|
|
957
|
-
- Payment method card; `resolvePaymentTitle
|
|
958
|
-
`
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
955
|
+
- Payment method card; `resolvePaymentTitle(providerId, titles,
|
|
956
|
+
methodName?)` — the method's merchant NAME wins verbatim when present
|
|
957
|
+
(the snapshot from session data); otherwise the processor id buckets
|
|
958
|
+
via `lib/payment-constants` (`pp_stripe` = card) through the locale
|
|
959
|
+
pack, falling back to `paymentInfoMap` then the raw id. Payment
|
|
960
|
+
internals never cross the Cartbase store surface — both arrive via
|
|
961
|
+
props from checkout state.
|
|
962
962
|
|
|
963
963
|
### `<OrderTimeline fulfillmentStatus? />` — `order/order-timeline`
|
|
964
964
|
|
|
@@ -975,8 +975,7 @@ component also takes a `labels` prop pick.
|
|
|
975
975
|
|
|
976
976
|
---
|
|
977
977
|
|
|
978
|
-
## Family: common (`@cartbase/storefront/common/*`)
|
|
979
|
-
|
|
978
|
+
## Family: common (`@cartbase/storefront/common/*`)
|
|
980
979
|
Shared storefront chrome, production-proven.
|
|
981
980
|
|
|
982
981
|
### `<LocalizedLink href … />` — `common/localized-link`
|
|
@@ -1028,8 +1027,7 @@ Shared storefront chrome, production-proven.
|
|
|
1028
1027
|
|
|
1029
1028
|
---
|
|
1030
1029
|
|
|
1031
|
-
## Family: reviews-ui (`@cartbase/storefront/reviews-ui`)
|
|
1032
|
-
|
|
1030
|
+
## Family: reviews-ui (`@cartbase/storefront/reviews-ui`)
|
|
1033
1031
|
Verified-purchase review components, ported from a production storefront,
|
|
1034
1032
|
over `api/reviews`. ONE barrel export seam: everything imports from
|
|
1035
1033
|
`@cartbase/storefront/reviews-ui`. Endpoint truth:
|