@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@porulle/adapter-woocommerce",
3
- "version": "0.77.0",
3
+ "version": "0.78.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "zod": "^4.1.11",
19
- "@porulle/core": "0.77.0"
19
+ "@porulle/core": "0.78.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/node": "^24.5.2",
package/src/catalog.ts CHANGED
@@ -13,6 +13,8 @@ export const wooVariationSchema = z.object({
13
13
  price: money,
14
14
  regular_price: money,
15
15
  sale_price: money,
16
+ /** GTIN, UPC, EAN or ISBN — core since WooCommerce 9.2; absent on older stores. */
17
+ global_unique_id: z.string().nullish(),
16
18
  status: z.string().nullish(),
17
19
  attributes: z.array(z.object({ name: z.string(), option: z.string().nullish() })).default([]),
18
20
  image: image.nullish(),
@@ -29,8 +31,12 @@ export const wooProductSchema = z.object({
29
31
  type: z.string(),
30
32
  status: z.string().nullish(),
31
33
  description: z.string().nullish(),
34
+ /** The summary WooCommerce shows above the add-to-cart button; often the only copy a store writes. */
35
+ short_description: z.string().nullish(),
32
36
  permalink: z.string().nullish(),
33
37
  sku: z.string().nullish(),
38
+ /** GTIN, UPC, EAN or ISBN — core since WooCommerce 9.2; a simple product's own barcode. */
39
+ global_unique_id: z.string().nullish(),
34
40
  price: money,
35
41
  regular_price: money,
36
42
  sale_price: money,
@@ -117,6 +123,7 @@ function variant(row: WooVariation, currency: string | undefined, resolve: (name
117
123
  return {
118
124
  externalId: row.id,
119
125
  ...(row.sku ? { sku: row.sku } : {}),
126
+ ...(row.global_unique_id?.trim() ? { barcode: row.global_unique_id.trim() } : {}),
120
127
  ...(Object.keys(optionValues).length > 0 ? { optionValues } : {}),
121
128
  ...(rowPrices ? { prices: rowPrices } : {}),
122
129
  };
@@ -148,7 +155,7 @@ export function catalogItem(product: WooProduct, variations: WooVariation[], cur
148
155
  const sellable = product.type === "simple" ? [] : variations.filter((row) => row.status !== "private");
149
156
  const { axes, resolve } = optionAxes(product, sellable);
150
157
  const variants = product.type === "simple"
151
- ? [variant({ id: product.id, sku: product.sku, price: product.price, regular_price: product.regular_price, sale_price: product.sale_price, attributes: [] }, currency, resolve)]
158
+ ? [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)]
152
159
  : sellable.map((row) => variant(row, currency, resolve));
153
160
  const options = product.type === "simple" ? [] : axes.map((axis, index) => ({
154
161
  name: axis.name,
@@ -157,12 +164,18 @@ export function catalogItem(product: WooProduct, variations: WooVariation[], cur
157
164
  values: axis.values.map((value, valueIndex) => ({ value, displayValue: value, sortOrder: valueIndex })),
158
165
  }));
159
166
  const itemStatus = status(product.status);
167
+ // Both of the store's copies, summary first, as the product page shows them: a store that writes
168
+ // only a short description would otherwise import with none.
169
+ const description = [product.short_description, product.description]
170
+ .map((part) => part?.trim() ?? "")
171
+ .filter((part) => part.length > 0)
172
+ .join("\n\n");
160
173
  return {
161
174
  externalId: product.id,
162
175
  slug: product.slug || product.id,
163
176
  title: product.name,
164
- ...(product.description ? { description: product.description } : {}),
165
- attributes: [{ locale: "en", title: product.name, ...(product.description ? { description: product.description } : {}) }],
177
+ ...(description ? { description } : {}),
178
+ attributes: [{ locale: "en", title: product.name, ...(description ? { description } : {}) }],
166
179
  variants,
167
180
  ...(images.length > 0 ? { images } : {}),
168
181
  ...(options.length > 0 ? { options } : {}),