@kizlo/woocommerce 0.2.2 → 0.3.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/test.js CHANGED
@@ -36,6 +36,14 @@ const PRODUCTS = [
36
36
  slug: "test-product-5",
37
37
  name: "Test Product 5",
38
38
  regular_price: "50"
39
+ },
40
+ {
41
+ slug: "test-product-locked",
42
+ name: "Test Product Locked",
43
+ regular_price: "60",
44
+ description: "Private product description",
45
+ short_description: "Private product summary",
46
+ post_password: "secret"
39
47
  }
40
48
  ];
41
49
  const COUPONS = [{
@@ -59,6 +67,30 @@ async function upsertCoupon(service, coupon) {
59
67
  const created = await service.post(`${WC_CORE_BASE}/coupons`, { body: coupon });
60
68
  if (created.error) throw created.error;
61
69
  }
70
+ async function upsertProductCategory(service) {
71
+ const existing = await service.get(`${WC_CORE_BASE}/products/categories`, { searchParams: { slug: "test-product-category" } });
72
+ if (existing.data?.[0]) return existing.data[0].id;
73
+ const created = await service.post(`${WC_CORE_BASE}/products/categories`, { body: {
74
+ name: "Test Product Category",
75
+ slug: "test-product-category"
76
+ } });
77
+ if (created.error) throw created.error;
78
+ return created.data.id;
79
+ }
80
+ async function linkProductCategory(service, productId) {
81
+ const categoryId = await upsertProductCategory(service);
82
+ const updated = await service.put(`${WC_CORE_BASE}/products/${productId}`, { body: { categories: [{ id: categoryId }] } });
83
+ if (updated.error) throw updated.error;
84
+ }
85
+ async function linkRecommendations(service, productIds) {
86
+ const [productId, upsellId, crossSellId] = productIds;
87
+ if (!productId || !upsellId || !crossSellId) return;
88
+ const updated = await service.put(`${WC_CORE_BASE}/products/${productId}`, { body: {
89
+ upsell_ids: [upsellId],
90
+ cross_sell_ids: [crossSellId]
91
+ } });
92
+ if (updated.error) throw updated.error;
93
+ }
62
94
  /**
63
95
  * WooCommerce ships every gateway disabled, and paying an order needs an available one, so the
64
96
  * checkout tests have nothing to reach without this. Bank transfer is the gateway with no shipping
@@ -100,10 +132,14 @@ function woocommerce(opts = {}) {
100
132
  },
101
133
  async seed({ service }) {
102
134
  let productId = 0;
135
+ const productIds = [];
103
136
  for (const product of PRODUCTS) {
104
137
  const id = await upsertProduct(service, product);
138
+ productIds.push(id);
105
139
  if (!productId) productId = id;
106
140
  }
141
+ if (productIds[0]) await linkProductCategory(service, productIds[0]);
142
+ await linkRecommendations(service, productIds);
107
143
  for (const coupon of COUPONS) await upsertCoupon(service, coupon);
108
144
  await enableBankTransfer(service);
109
145
  return { productId };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizlo/woocommerce",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "WooCommerce integration for Kizlo.",
@@ -49,7 +49,7 @@
49
49
  "access": "public"
50
50
  },
51
51
  "dependencies": {
52
- "@kizlo/shared": "0.8.0",
52
+ "@kizlo/shared": "0.9.0",
53
53
  "jose": "6.1.0",
54
54
  "zod": "^4.3.6"
55
55
  },