@asstio-dev/storefront 0.16.1 → 0.16.3
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/README.md +38 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -412,6 +412,44 @@ Problem codes you will meet here: `CART_EMPTY`, `CHECKOUT_CART_CHANGED` (with `c
|
|
|
412
412
|
|
|
413
413
|
`https://*.kustom.co` covers the playground (`js.playground.kustom.co`) and production (`js.kustom.co`).
|
|
414
414
|
|
|
415
|
+
### Shipping
|
|
416
|
+
|
|
417
|
+
The shopper chooses delivery inside the provider's widget (Kustom's shipping assistant, Qliro's shipping step), so
|
|
418
|
+
there is **no shipping picker to build and no price, VAT or method id to send**. The `klarna-kco` (Kustom) and `qliro-q1`
|
|
419
|
+
controllers answer for the widget; the page's part is the estimate before the checkout and the shipping block on the order.
|
|
420
|
+
|
|
421
|
+
```ts
|
|
422
|
+
// The estimate: an estimate, never a quote (the destination is not known yet). No lookup, `no-store`.
|
|
423
|
+
const { data: estimate } = await storefront.GET("/v1/cart/shipping-estimate", {
|
|
424
|
+
params: { header: { "X-Cart-Token": token } },
|
|
425
|
+
});
|
|
426
|
+
if (estimate?.available) {
|
|
427
|
+
const headline = estimate.options.find((option) => option.preselected); // `fee` is gross kronor, "49.00"
|
|
428
|
+
// estimate.freeShipping: { free, threshold, remaining } — progress comes from here, never a hard-coded threshold
|
|
429
|
+
}
|
|
430
|
+
// `available: false` means show nothing about shipping. `reason: null`: no block published on the market, and the
|
|
431
|
+
// checkout works as before. `reason: "unavailable"`: a block that cannot be served now; the cart works, but
|
|
432
|
+
// POST /v1/checkout refuses a new attempt with 503 SHIPPING_UNAVAILABLE (Retry-After 60) until it is fixed.
|
|
433
|
+
|
|
434
|
+
// The order page: `order.shipping` is `OrderShippingDto | null`.
|
|
435
|
+
// null = the selection was not matched or confirmed (the charged shipping line is still in `order.lines`), or the
|
|
436
|
+
// market has no block. Show the block only when it is present; never read null as "no shipping was paid".
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
- `ShippingEstimateOptionDto`: `key`, `name`, `deliveryType` (`delivery`, `pickup` or `mailbox`), `fee`, `regularFee`
|
|
440
|
+
(the price without the free-shipping rule; set only when `fee` is `"0.00"` and that price is above 0, so `null`
|
|
441
|
+
for an always-free method: render no comparison price then), `labels`, `pointsAtCheckout` (the pickup point is
|
|
442
|
+
chosen in the checkout; none is listed here) and `preselected`. The estimate has **no delivery time**.
|
|
443
|
+
- `OrderShippingDto`: `option`, `name`, `deliveryType`, `carrier`, `fee`, `point` (name, street, postal code, city; null
|
|
444
|
+
when the carrier assigned it or after the privacy scrub) and `deliveryTime` (`mode` `carrierEstimate`, `fixed` or
|
|
445
|
+
`text`; `minDays` and `maxDays` are each nullable: render only the bounds that are present, or `text`).
|
|
446
|
+
- **Do not re-render the widget** when shipping changes, and do not write your own Qliro unlock: on a market with a
|
|
447
|
+
shipping block Qliro's total includes the fee and so can differ from the cart's, and the `qliro-q1` controller unlocks on the echoed cart version
|
|
448
|
+
(`MerchantUpdateVersion`) or on the confirmed total (see the Qliro notes above).
|
|
449
|
+
- Shipping never blocks a purchase. If a selection cannot be matched when the shopper pays, the order is accepted and
|
|
450
|
+
normally held in Asstio with its reason (rarely the export waits for an operator instead); the page has nothing to
|
|
451
|
+
do for it.
|
|
452
|
+
|
|
415
453
|
## Headers
|
|
416
454
|
|
|
417
455
|
Every call the client makes carries these; you never set them by hand.
|