@shoppexio/storefront 1.0.93 → 1.0.95
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/CHANGELOG.md +9 -0
- package/dist/index.cjs +9 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.95
|
|
4
|
+
|
|
5
|
+
- `Product.sku` and `ProductVariant.sku` / `PriceVariant.sku` carry the merchant's SKU (`null` when they set none). `getProduct` keeps each option's SKU on `product.variants`; before, the mapper dropped it (PR #3719).
|
|
6
|
+
|
|
7
|
+
## 1.0.94
|
|
8
|
+
|
|
9
|
+
- `getProduct(idOrSlug, { variant })` reads a product for a variant's direct link (`?variant=<id>`). A private variant (`is_private: true`) is listed only when it is named this way; it then comes first in `price_variants`, so a buy box that opens on the first sellable option preselects it. Product lists never carry a private variant.
|
|
10
|
+
|
|
3
11
|
## 1.0.93
|
|
4
12
|
|
|
13
|
+
- `undoSubscriptionCancel(uniqid)` takes back a scheduled cancellation of the signed-in customer's subscription before its period ends (PR #3696).
|
|
5
14
|
- Select custom fields: `StorefrontCustomField.options` lists the labels of a `type: "select"` field, and `validateStorefrontCustomFieldValue` refuses any other answer with "<name> must be one of the listed options." (the server refuses it with `custom_field_option_invalid`). Draw a select as a dropdown of exactly these labels.
|
|
6
15
|
- `normalizeStorefrontCustomFields` leaves out fields the merchant collects after payment (`collect_after_payment`). The buyer answers those on the invoice after paying, and the server drops a value the cart sends for them.
|
|
7
16
|
- `Product.addons_required`: the buyer must pick one of the product's `addons`; the server refuses a cart or invoice line that names none with `errors.checkout.addon_required`. It asks nothing when `addons` is empty. Send the buyer to the product page to choose; never add an add-on for them.
|
package/dist/index.cjs
CHANGED
|
@@ -1354,6 +1354,7 @@ function priceVariantToProductVariant(variant) {
|
|
|
1354
1354
|
id: variant.id,
|
|
1355
1355
|
title: variant.title ?? variant.label ?? "",
|
|
1356
1356
|
price: typeof variant.price === "number" ? variant.price : Number(variant.price) || 0,
|
|
1357
|
+
sku: variant.sku,
|
|
1357
1358
|
stock: typeof variant.stock === "number" ? variant.stock : void 0,
|
|
1358
1359
|
// Dynamic Delivery (S8): carry the availability pair through. A supplier-backed
|
|
1359
1360
|
// variant reports `stock: 0`, so dropping `orderable` here would make the mapped
|
|
@@ -1370,7 +1371,8 @@ function priceVariantToProductVariant(variant) {
|
|
|
1370
1371
|
cloudflare_image_id: variant.cloudflare_image_id,
|
|
1371
1372
|
cloudflareImageId: variant.cloudflareImageId,
|
|
1372
1373
|
image_url: variant.image_url,
|
|
1373
|
-
imageUrl: variant.imageUrl
|
|
1374
|
+
imageUrl: variant.imageUrl,
|
|
1375
|
+
is_private: variant.is_private
|
|
1374
1376
|
};
|
|
1375
1377
|
}
|
|
1376
1378
|
function normalizeProduct(product) {
|
|
@@ -1454,7 +1456,7 @@ async function getStorefrontProductsPage(options) {
|
|
|
1454
1456
|
}
|
|
1455
1457
|
return forwardFailure(response);
|
|
1456
1458
|
}
|
|
1457
|
-
async function getProduct(idOrSlug) {
|
|
1459
|
+
async function getProduct(idOrSlug, options = {}) {
|
|
1458
1460
|
let shopId = getShopId();
|
|
1459
1461
|
if (!shopId) {
|
|
1460
1462
|
const store = await getStore();
|
|
@@ -1463,13 +1465,16 @@ async function getProduct(idOrSlug) {
|
|
|
1463
1465
|
}
|
|
1464
1466
|
shopId = store.data?.id ?? null;
|
|
1465
1467
|
}
|
|
1466
|
-
const
|
|
1468
|
+
const query = new URLSearchParams();
|
|
1469
|
+
if (shopId) query.set("slug_shop_id", shopId);
|
|
1470
|
+
if (options.variant) query.set("variant", options.variant);
|
|
1471
|
+
const queryParams = query.size > 0 ? `?${query.toString()}` : "";
|
|
1467
1472
|
const response = await get(
|
|
1468
1473
|
`${buildEndpoint("/v1/storefront/products/unique/:idOrSlug", { idOrSlug })}${queryParams}`,
|
|
1469
1474
|
{
|
|
1470
1475
|
buyerCurrency: true,
|
|
1471
1476
|
cache: {
|
|
1472
|
-
key: `product:${idOrSlug}:${shopId ?? "no-shop"}`,
|
|
1477
|
+
key: `product:${idOrSlug}:${shopId ?? "no-shop"}:${options.variant ?? "no-variant"}`,
|
|
1473
1478
|
ttl: PRODUCTS_CACHE_TTL,
|
|
1474
1479
|
staleWhileRevalidate: true
|
|
1475
1480
|
}
|