@porulle/adapter-woocommerce 0.77.0 → 0.78.0
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/catalog.d.ts +3 -0
- package/dist/catalog.js +16 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/catalog.ts +16 -3
package/dist/catalog.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare const wooVariationSchema: z.ZodObject<{
|
|
|
7
7
|
price: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8
8
|
regular_price: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
9
9
|
sale_price: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
|
+
global_unique_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
10
11
|
status: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
12
|
attributes: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
12
13
|
name: z.ZodString;
|
|
@@ -29,8 +30,10 @@ export declare const wooProductSchema: z.ZodObject<{
|
|
|
29
30
|
type: z.ZodString;
|
|
30
31
|
status: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
31
32
|
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
|
+
short_description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
34
|
permalink: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
33
35
|
sku: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
|
+
global_unique_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
37
|
price: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
38
|
regular_price: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
36
39
|
sale_price: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
package/dist/catalog.js
CHANGED
|
@@ -9,6 +9,8 @@ export const wooVariationSchema = z.object({
|
|
|
9
9
|
price: money,
|
|
10
10
|
regular_price: money,
|
|
11
11
|
sale_price: money,
|
|
12
|
+
/** GTIN, UPC, EAN or ISBN — core since WooCommerce 9.2; absent on older stores. */
|
|
13
|
+
global_unique_id: z.string().nullish(),
|
|
12
14
|
status: z.string().nullish(),
|
|
13
15
|
attributes: z.array(z.object({ name: z.string(), option: z.string().nullish() })).default([]),
|
|
14
16
|
image: image.nullish(),
|
|
@@ -23,8 +25,12 @@ export const wooProductSchema = z.object({
|
|
|
23
25
|
type: z.string(),
|
|
24
26
|
status: z.string().nullish(),
|
|
25
27
|
description: z.string().nullish(),
|
|
28
|
+
/** The summary WooCommerce shows above the add-to-cart button; often the only copy a store writes. */
|
|
29
|
+
short_description: z.string().nullish(),
|
|
26
30
|
permalink: z.string().nullish(),
|
|
27
31
|
sku: z.string().nullish(),
|
|
32
|
+
/** GTIN, UPC, EAN or ISBN — core since WooCommerce 9.2; a simple product's own barcode. */
|
|
33
|
+
global_unique_id: z.string().nullish(),
|
|
28
34
|
price: money,
|
|
29
35
|
regular_price: money,
|
|
30
36
|
sale_price: money,
|
|
@@ -108,6 +114,7 @@ function variant(row, currency, resolve) {
|
|
|
108
114
|
return {
|
|
109
115
|
externalId: row.id,
|
|
110
116
|
...(row.sku ? { sku: row.sku } : {}),
|
|
117
|
+
...(row.global_unique_id?.trim() ? { barcode: row.global_unique_id.trim() } : {}),
|
|
111
118
|
...(Object.keys(optionValues).length > 0 ? { optionValues } : {}),
|
|
112
119
|
...(rowPrices ? { prices: rowPrices } : {}),
|
|
113
120
|
};
|
|
@@ -140,7 +147,7 @@ export function catalogItem(product, variations, currency) {
|
|
|
140
147
|
const sellable = product.type === "simple" ? [] : variations.filter((row) => row.status !== "private");
|
|
141
148
|
const { axes, resolve } = optionAxes(product, sellable);
|
|
142
149
|
const variants = product.type === "simple"
|
|
143
|
-
? [variant({ id: product.id, sku: product.sku, price: product.price, regular_price: product.regular_price, sale_price: product.sale_price, attributes: [] }, currency, resolve)]
|
|
150
|
+
? [variant({ id: product.id, sku: product.sku, global_unique_id: product.global_unique_id, price: product.price, regular_price: product.regular_price, sale_price: product.sale_price, attributes: [] }, currency, resolve)]
|
|
144
151
|
: sellable.map((row) => variant(row, currency, resolve));
|
|
145
152
|
const options = product.type === "simple" ? [] : axes.map((axis, index) => ({
|
|
146
153
|
name: axis.name,
|
|
@@ -149,12 +156,18 @@ export function catalogItem(product, variations, currency) {
|
|
|
149
156
|
values: axis.values.map((value, valueIndex) => ({ value, displayValue: value, sortOrder: valueIndex })),
|
|
150
157
|
}));
|
|
151
158
|
const itemStatus = status(product.status);
|
|
159
|
+
// Both of the store's copies, summary first, as the product page shows them: a store that writes
|
|
160
|
+
// only a short description would otherwise import with none.
|
|
161
|
+
const description = [product.short_description, product.description]
|
|
162
|
+
.map((part) => part?.trim() ?? "")
|
|
163
|
+
.filter((part) => part.length > 0)
|
|
164
|
+
.join("\n\n");
|
|
152
165
|
return {
|
|
153
166
|
externalId: product.id,
|
|
154
167
|
slug: product.slug || product.id,
|
|
155
168
|
title: product.name,
|
|
156
|
-
...(
|
|
157
|
-
attributes: [{ locale: "en", title: product.name, ...(
|
|
169
|
+
...(description ? { description } : {}),
|
|
170
|
+
attributes: [{ locale: "en", title: product.name, ...(description ? { description } : {}) }],
|
|
158
171
|
variants,
|
|
159
172
|
...(images.length > 0 ? { images } : {}),
|
|
160
173
|
...(options.length > 0 ? { options } : {}),
|