@kizlo/woocommerce 0.7.0 → 0.9.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/index.d.ts +7 -1
- package/dist/index.js +53 -53
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as zod_v4_core0 from "zod/v4/core";
|
|
|
8
8
|
//#region src/product/types.d.ts
|
|
9
9
|
|
|
10
10
|
/** The exact resolved custom-field shape configured for products on this WordPress site. */
|
|
11
|
-
type ProductCustomFields = WP_CustomFields<"postTypes.product">;
|
|
11
|
+
type ProductCustomFields = WP_CustomFields<"kizlo.postTypes.product">;
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/cart/schema.d.ts
|
|
14
14
|
declare const CartAdditionalFields: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnion<readonly [z$1.ZodString, z$1.ZodBoolean]>>;
|
|
@@ -658,6 +658,7 @@ declare const Checkout: z$2.ZodObject<{
|
|
|
658
658
|
orderNumber: z$2.ZodNullable<z$2.ZodString>;
|
|
659
659
|
orderKey: z$2.ZodNullable<z$2.ZodString>;
|
|
660
660
|
status: z$2.ZodString;
|
|
661
|
+
isPaid: z$2.ZodBoolean;
|
|
661
662
|
customerId: z$2.ZodNullable<z$2.ZodNumber>;
|
|
662
663
|
customerNote: z$2.ZodString;
|
|
663
664
|
billingAddress: z$2.ZodObject<{
|
|
@@ -1219,6 +1220,7 @@ type OrderTotals = z.infer<typeof OrderTotals>;
|
|
|
1219
1220
|
declare const Order: z.ZodObject<{
|
|
1220
1221
|
id: z.ZodNumber;
|
|
1221
1222
|
status: z.ZodString;
|
|
1223
|
+
isPaid: z.ZodBoolean;
|
|
1222
1224
|
items: z.ZodArray<z.ZodObject<{
|
|
1223
1225
|
id: z.ZodNumber;
|
|
1224
1226
|
productId: z.ZodNullable<z.ZodNumber>;
|
|
@@ -6187,6 +6189,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
6187
6189
|
orderNumber: string | null;
|
|
6188
6190
|
orderKey: string | null;
|
|
6189
6191
|
status: string;
|
|
6192
|
+
isPaid: boolean;
|
|
6190
6193
|
customerId: number | null;
|
|
6191
6194
|
customerNote: string;
|
|
6192
6195
|
billingAddress: {
|
|
@@ -6562,6 +6565,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
6562
6565
|
orderNumber: string | null;
|
|
6563
6566
|
orderKey: string | null;
|
|
6564
6567
|
status: string;
|
|
6568
|
+
isPaid: boolean;
|
|
6565
6569
|
customerId: number | null;
|
|
6566
6570
|
customerNote: string;
|
|
6567
6571
|
billingAddress: {
|
|
@@ -8498,6 +8502,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
8498
8502
|
orderNumber: string | null;
|
|
8499
8503
|
orderKey: string | null;
|
|
8500
8504
|
status: string;
|
|
8505
|
+
isPaid: boolean;
|
|
8501
8506
|
customerId: number | null;
|
|
8502
8507
|
customerNote: string;
|
|
8503
8508
|
billingAddress: {
|
|
@@ -11085,6 +11090,7 @@ declare function woocommerce(): kizlo0.Integration<"woocommerce", {
|
|
|
11085
11090
|
orderNumber: string | null;
|
|
11086
11091
|
orderKey: string | null;
|
|
11087
11092
|
status: string;
|
|
11093
|
+
isPaid: boolean;
|
|
11088
11094
|
customerId: number | null;
|
|
11089
11095
|
customerNote: string;
|
|
11090
11096
|
billingAddress: {
|
package/dist/index.js
CHANGED
|
@@ -1203,7 +1203,7 @@ const CART_PROCEDURES = {
|
|
|
1203
1203
|
errors: GET_CART_ERROR_MAP,
|
|
1204
1204
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1205
1205
|
}, async ({ context, errors }) => {
|
|
1206
|
-
const response = await context.wordpress.woocommerce.store.cart.
|
|
1206
|
+
const response = await context.wordpress.woocommerce.store.cart.retrieve({}, { headers: context.sessionHeaders });
|
|
1207
1207
|
if (response.error) switch (response.error.code) {
|
|
1208
1208
|
default:
|
|
1209
1209
|
context.logger.error("Get cart unhandled error", response.error, { code: response.error.code });
|
|
@@ -1220,7 +1220,7 @@ const CART_PROCEDURES = {
|
|
|
1220
1220
|
errors: UPDATE_CART_ERROR_MAP,
|
|
1221
1221
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1222
1222
|
}, async ({ context, input: { body: input }, errors }) => {
|
|
1223
|
-
const response = await context.wordpress.woocommerce.store.cart.updateCustomer(serializeCartUpdateInput(input), { headers: context.sessionHeaders });
|
|
1223
|
+
const response = await context.wordpress.woocommerce.store.cart.updateCustomer.create({ body: serializeCartUpdateInput(input) }, { headers: context.sessionHeaders });
|
|
1224
1224
|
if (response.error) switch (response.error.code) {
|
|
1225
1225
|
case "rest_invalid_param":
|
|
1226
1226
|
case "woocommerce_rest_invalid_address":
|
|
@@ -1242,10 +1242,10 @@ const CART_PROCEDURES = {
|
|
|
1242
1242
|
errors: SELECT_SHIPPING_RATE_ERROR_MAP,
|
|
1243
1243
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1244
1244
|
}, async ({ context, input: { body }, errors }) => {
|
|
1245
|
-
const response = await context.wordpress.woocommerce.store.cart.selectShippingRate({
|
|
1245
|
+
const response = await context.wordpress.woocommerce.store.cart.selectShippingRate.create({ body: {
|
|
1246
1246
|
rate_id: body.rateId,
|
|
1247
1247
|
package_id: body.packageId
|
|
1248
|
-
}, { headers: context.sessionHeaders });
|
|
1248
|
+
} }, { headers: context.sessionHeaders });
|
|
1249
1249
|
if (response.error) switch (response.error.code) {
|
|
1250
1250
|
case "woocommerce_rest_cart_shipping_rate_not_found": throw errors.CART_SHIPPING_RATE_NOT_FOUND({ message: response.error.message });
|
|
1251
1251
|
case "woocommerce_rest_shipping_disabled": throw errors.CART_SHIPPING_DISABLED({ message: response.error.message });
|
|
@@ -1265,11 +1265,11 @@ const CART_PROCEDURES = {
|
|
|
1265
1265
|
errors: ADD_CART_ITEM_ERROR_MAP,
|
|
1266
1266
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1267
1267
|
}, async ({ context, input: { body: input }, errors }) => {
|
|
1268
|
-
const response = await context.wordpress.woocommerce.store.cart.addItem({
|
|
1268
|
+
const response = await context.wordpress.woocommerce.store.cart.addItem.create({ body: {
|
|
1269
1269
|
id: input.variationId ?? input.productId,
|
|
1270
1270
|
quantity: input.quantity,
|
|
1271
1271
|
variation: input.selectedAttributes ?? []
|
|
1272
|
-
}, { headers: context.sessionHeaders });
|
|
1272
|
+
} }, { headers: context.sessionHeaders });
|
|
1273
1273
|
if (response.error) switch (response.error.code) {
|
|
1274
1274
|
case "woocommerce_rest_product_out_of_stock": throw errors.CART_ITEM_OUT_OF_STOCK({ message: response.error.message });
|
|
1275
1275
|
case "woocommerce_rest_product_partially_out_of_stock": throw errors.CART_ITEM_INSUFFICIENT_STOCK({ message: response.error.message });
|
|
@@ -1298,10 +1298,10 @@ const CART_PROCEDURES = {
|
|
|
1298
1298
|
errors: UPDATE_CART_ITEM_ERROR_MAP,
|
|
1299
1299
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1300
1300
|
}, async ({ context, input: { params, body }, errors }) => {
|
|
1301
|
-
const response = await context.wordpress.woocommerce.store.cart.updateItem({
|
|
1301
|
+
const response = await context.wordpress.woocommerce.store.cart.updateItem.create({ body: {
|
|
1302
1302
|
key: params.key,
|
|
1303
1303
|
quantity: body.quantity
|
|
1304
|
-
}, { headers: context.sessionHeaders });
|
|
1304
|
+
} }, { headers: context.sessionHeaders });
|
|
1305
1305
|
if (response.error) switch (response.error.code) {
|
|
1306
1306
|
case "woocommerce_rest_cart_invalid_key": throw errors.CART_ITEM_NOT_FOUND({ message: response.error.message });
|
|
1307
1307
|
case "woocommerce_rest_cart_invalid_product": throw errors.CART_PRODUCT_INVALID({ message: response.error.message });
|
|
@@ -1323,7 +1323,7 @@ const CART_PROCEDURES = {
|
|
|
1323
1323
|
errors: REMOVE_CART_ITEM_ERROR_MAP,
|
|
1324
1324
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1325
1325
|
}, async ({ context, input: { params }, errors }) => {
|
|
1326
|
-
const response = await context.wordpress.woocommerce.store.cart.removeItem({ key: params.key }, { headers: context.sessionHeaders });
|
|
1326
|
+
const response = await context.wordpress.woocommerce.store.cart.removeItem.create({ body: { key: params.key } }, { headers: context.sessionHeaders });
|
|
1327
1327
|
if (response.error) switch (response.error.code) {
|
|
1328
1328
|
case "woocommerce_rest_cart_invalid_key": throw errors.CART_ITEM_NOT_FOUND({ message: response.error.message });
|
|
1329
1329
|
default:
|
|
@@ -1343,7 +1343,7 @@ const CART_PROCEDURES = {
|
|
|
1343
1343
|
errors: APPLY_COUPON_ERROR_MAP,
|
|
1344
1344
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1345
1345
|
}, async ({ context, input: { body }, errors }) => {
|
|
1346
|
-
const response = await context.wordpress.woocommerce.store.cart.applyCoupon({ code: body.code }, { headers: context.sessionHeaders });
|
|
1346
|
+
const response = await context.wordpress.woocommerce.store.cart.applyCoupon.create({ body: { code: body.code } }, { headers: context.sessionHeaders });
|
|
1347
1347
|
if (response.error) switch (response.error.code) {
|
|
1348
1348
|
case "woocommerce_rest_cart_coupon_error": throw errors.CART_COUPON_INVALID({ message: response.error.message });
|
|
1349
1349
|
case "woocommerce_rest_cart_coupon_disabled": throw errors.CART_COUPON_DISABLED({ message: response.error.message });
|
|
@@ -1362,7 +1362,7 @@ const CART_PROCEDURES = {
|
|
|
1362
1362
|
errors: REMOVE_COUPON_ERROR_MAP,
|
|
1363
1363
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1364
1364
|
}, async ({ context, input, errors }) => {
|
|
1365
|
-
const response = await context.wordpress.woocommerce.store.cart.removeCoupon({ code: input.params.code }, { headers: context.sessionHeaders });
|
|
1365
|
+
const response = await context.wordpress.woocommerce.store.cart.removeCoupon.create({ body: { code: input.params.code } }, { headers: context.sessionHeaders });
|
|
1366
1366
|
if (response.error) switch (response.error.code) {
|
|
1367
1367
|
case "woocommerce_rest_cart_coupon_error": throw errors.CART_COUPON_INVALID({ message: response.error.message });
|
|
1368
1368
|
case "woocommerce_rest_cart_coupon_disabled": throw errors.CART_COUPON_DISABLED({ message: response.error.message });
|
|
@@ -1588,6 +1588,7 @@ const Checkout = z$2.object({
|
|
|
1588
1588
|
orderNumber: z$2.string().nullable(),
|
|
1589
1589
|
orderKey: z$2.string().nullable(),
|
|
1590
1590
|
status: z$2.string(),
|
|
1591
|
+
isPaid: z$2.boolean(),
|
|
1591
1592
|
customerId: z$2.number().nullable(),
|
|
1592
1593
|
customerNote: z$2.string(),
|
|
1593
1594
|
billingAddress: CartBillingAddress,
|
|
@@ -1644,13 +1645,14 @@ function gateway(method) {
|
|
|
1644
1645
|
return method;
|
|
1645
1646
|
}
|
|
1646
1647
|
function deserializeCheckout(data) {
|
|
1647
|
-
const { extensions } = deserializeExtensions(data.extensions);
|
|
1648
|
+
const { extensions, kizlo } = deserializeExtensions(data.extensions);
|
|
1648
1649
|
const paymentResult = data.payment_result;
|
|
1649
1650
|
return {
|
|
1650
1651
|
orderId: data.order_id === 0 ? null : data.order_id,
|
|
1651
1652
|
orderNumber: data.order_number === "" || data.order_number === "0" ? null : data.order_number,
|
|
1652
1653
|
orderKey: data.order_key === "" ? null : data.order_key,
|
|
1653
1654
|
status: data.status,
|
|
1655
|
+
isPaid: kizlo.is_paid === true,
|
|
1654
1656
|
customerId: data.customer_id === 0 ? null : data.customer_id,
|
|
1655
1657
|
customerNote: data.customer_note,
|
|
1656
1658
|
billingAddress: deserializeCartBillingAddress(data.billing_address),
|
|
@@ -1708,7 +1710,7 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1708
1710
|
errors: GET_CHECKOUT_ERROR_MAP,
|
|
1709
1711
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1710
1712
|
}, async ({ context, errors }) => {
|
|
1711
|
-
const response = await context.wordpress.woocommerce.store.checkout.
|
|
1713
|
+
const response = await context.wordpress.woocommerce.store.checkout.retrieve({}, { headers: context.sessionHeaders });
|
|
1712
1714
|
if (response.error) {
|
|
1713
1715
|
if (response.error.code === "woocommerce_rest_checkout_missing_order") throw errors.CHECKOUT_ORDER_NOT_FOUND({ message: response.error.message });
|
|
1714
1716
|
context.logger.error("Get checkout unhandled error", response.error, { code: response.error.code });
|
|
@@ -1725,13 +1727,13 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1725
1727
|
errors: UPDATE_CHECKOUT_ERROR_MAP,
|
|
1726
1728
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1727
1729
|
}, async ({ context, input, errors }) => {
|
|
1728
|
-
const response = await context.wordpress.woocommerce.store.checkout.update({
|
|
1730
|
+
const response = await context.wordpress.woocommerce.store.checkout.update({ body: {
|
|
1729
1731
|
order_notes: input.body.customerNote,
|
|
1730
1732
|
payment_method: gateway(input.body.paymentMethod),
|
|
1731
1733
|
additional_fields: input.body.additionalFields,
|
|
1732
1734
|
extensions: input.body.extensions,
|
|
1733
1735
|
__experimental_calc_totals: input.body.recalculateTotals
|
|
1734
|
-
}, { headers: context.sessionHeaders });
|
|
1736
|
+
} }, { headers: context.sessionHeaders });
|
|
1735
1737
|
if (response.error) {
|
|
1736
1738
|
const conflict = conflictData(response.error.data);
|
|
1737
1739
|
switch (response.error.code) {
|
|
@@ -1778,7 +1780,7 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1778
1780
|
errors: CONFIRM_CHECKOUT_ERROR_MAP,
|
|
1779
1781
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1780
1782
|
}, async ({ context, input, errors }) => {
|
|
1781
|
-
const response = await context.wordpress.woocommerce.store.checkout.
|
|
1783
|
+
const response = await context.wordpress.woocommerce.store.checkout.create({ body: {
|
|
1782
1784
|
billing_address: serializeCheckoutBillingAddress(input.body.billingAddress),
|
|
1783
1785
|
shipping_address: input.body.shippingAddress ? serializeCheckoutShippingAddress(input.body.shippingAddress) : void 0,
|
|
1784
1786
|
payment_method: gateway(input.body.paymentMethod),
|
|
@@ -1791,7 +1793,7 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1791
1793
|
successPath: input.body.successPath,
|
|
1792
1794
|
cancelPath: input.body.cancelPath
|
|
1793
1795
|
})
|
|
1794
|
-
}, { headers: context.sessionHeaders });
|
|
1796
|
+
} }, { headers: context.sessionHeaders });
|
|
1795
1797
|
if (response.error) {
|
|
1796
1798
|
const conflict = conflictData(response.error.data);
|
|
1797
1799
|
switch (response.error.code) {
|
|
@@ -1863,20 +1865,22 @@ const CHECKOUT_PROCEDURES = {
|
|
|
1863
1865
|
errors: RETRY_CHECKOUT_ERROR_MAP,
|
|
1864
1866
|
middlewares: [sessionMiddleware({ transitionGuestCart: true })]
|
|
1865
1867
|
}, async ({ context, input, errors }) => {
|
|
1866
|
-
const response = await context.wordpress.woocommerce.store.checkout.
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1868
|
+
const response = await context.wordpress.woocommerce.store.checkout.updateById({
|
|
1869
|
+
params: { id: String(input.params.orderId) },
|
|
1870
|
+
body: {
|
|
1871
|
+
key: input.body.key,
|
|
1872
|
+
payment_data: input.body.paymentData,
|
|
1873
|
+
billing_email: input.body.billingEmail,
|
|
1874
|
+
payment_method: gateway(input.body.paymentMethod),
|
|
1875
|
+
billing_address: serializeCheckoutBillingAddress(input.body.billingAddress),
|
|
1876
|
+
shipping_address: input.body.shippingAddress ? serializeCheckoutShippingAddress(input.body.shippingAddress) : void 0,
|
|
1877
|
+
customer_note: input.body.customerNote,
|
|
1878
|
+
additional_fields: input.body.additionalFields,
|
|
1879
|
+
extensions: withKizloRedirectPaths(input.body.extensions, {
|
|
1880
|
+
successPath: input.body.successPath,
|
|
1881
|
+
cancelPath: input.body.cancelPath
|
|
1882
|
+
})
|
|
1883
|
+
}
|
|
1880
1884
|
}, { headers: context.sessionHeaders });
|
|
1881
1885
|
if (response.error) switch (response.error.code) {
|
|
1882
1886
|
case "rest_invalid_param": throw errors.CHECKOUT_VALIDATION_FAILED({
|
|
@@ -2027,10 +2031,10 @@ const CUSTOMER_PROCEDURES = { get: createProcedure({
|
|
|
2027
2031
|
}, async ({ context, errors }) => {
|
|
2028
2032
|
const session = await context.getSession();
|
|
2029
2033
|
if (!session) throw errors.FORBIDDEN();
|
|
2030
|
-
const response = await context.wordpress.woocommerce.customers.list({
|
|
2034
|
+
const response = await context.wordpress.woocommerce.customers.list({ query: {
|
|
2031
2035
|
email: session.email,
|
|
2032
2036
|
role: "all"
|
|
2033
|
-
});
|
|
2037
|
+
} });
|
|
2034
2038
|
if (response.error) switch (response.error.code) {
|
|
2035
2039
|
case "woocommerce_rest_cannot_view": throw errors.FORBIDDEN();
|
|
2036
2040
|
default:
|
|
@@ -2108,6 +2112,7 @@ const OrderTotals = z.object({
|
|
|
2108
2112
|
const Order = z.object({
|
|
2109
2113
|
id: z.number(),
|
|
2110
2114
|
status: z.string(),
|
|
2115
|
+
isPaid: z.boolean(),
|
|
2111
2116
|
items: z.array(OrderItem),
|
|
2112
2117
|
coupons: z.array(CartCoupon),
|
|
2113
2118
|
fees: z.array(OrderFee),
|
|
@@ -2146,9 +2151,11 @@ assertNoMissing();
|
|
|
2146
2151
|
assertNoMissing();
|
|
2147
2152
|
assertNoMissing();
|
|
2148
2153
|
function deserializeOrder(data) {
|
|
2154
|
+
const { kizlo } = deserializeExtensions(data.extensions);
|
|
2149
2155
|
return {
|
|
2150
2156
|
id: data.id,
|
|
2151
2157
|
status: data.status,
|
|
2158
|
+
isPaid: kizlo.is_paid === true,
|
|
2152
2159
|
items: data.items.map(deserializeOrderItem),
|
|
2153
2160
|
coupons: data.coupons.map((coupon) => ({
|
|
2154
2161
|
code: coupon.code,
|
|
@@ -2273,10 +2280,12 @@ const ORDER_PROCEDURES = { get: createProcedure({
|
|
|
2273
2280
|
errors: GET_ORDER_ERROR_MAP,
|
|
2274
2281
|
middlewares: [sessionMiddleware()]
|
|
2275
2282
|
}, async ({ context, input, errors }) => {
|
|
2276
|
-
const response = await context.wordpress.woocommerce.store.
|
|
2277
|
-
id: input.params.orderId,
|
|
2278
|
-
|
|
2279
|
-
|
|
2283
|
+
const response = await context.wordpress.woocommerce.store.order.retrieve({
|
|
2284
|
+
params: { id: String(input.params.orderId) },
|
|
2285
|
+
query: {
|
|
2286
|
+
key: input.query?.key,
|
|
2287
|
+
billing_email: input.query?.billingEmail
|
|
2288
|
+
}
|
|
2280
2289
|
}, { headers: context.sessionHeaders });
|
|
2281
2290
|
if (response.error) switch (response.error.code) {
|
|
2282
2291
|
case "woocommerce_rest_invalid_order":
|
|
@@ -2321,7 +2330,7 @@ const PRODUCT_PROCEDURES = {
|
|
|
2321
2330
|
if (input.query?.previewToken) {
|
|
2322
2331
|
const result = await context.verifyPreviewToken(input.query.previewToken);
|
|
2323
2332
|
if (!result) throw errors.PRODUCT_NOT_FOUND();
|
|
2324
|
-
const response$1 = await context.wordpress.woocommerce.products.retrieve({ id: Number(result.id) });
|
|
2333
|
+
const response$1 = await context.wordpress.woocommerce.products.retrieve({ params: { id: Number(result.id) } });
|
|
2325
2334
|
if (response$1.error) switch (response$1.error.code) {
|
|
2326
2335
|
case "woocommerce_rest_product_invalid_id": throw errors.PRODUCT_NOT_FOUND({ message: response$1.error.message });
|
|
2327
2336
|
default:
|
|
@@ -2336,13 +2345,7 @@ const PRODUCT_PROCEDURES = {
|
|
|
2336
2345
|
const identifier = input.params.identifier;
|
|
2337
2346
|
const includeRecommendations = input.query?.recommendations ?? false;
|
|
2338
2347
|
const embeds = includeRecommendations ? { _embed: PRODUCT_EMBEDS } : {};
|
|
2339
|
-
const response = typeof identifier === "number" ? await context.wordpress.woocommerce.store.products.
|
|
2340
|
-
id: identifier,
|
|
2341
|
-
...embeds
|
|
2342
|
-
}) : await context.wordpress.woocommerce.store.products.getBySlug({
|
|
2343
|
-
slug: identifier,
|
|
2344
|
-
...embeds
|
|
2345
|
-
});
|
|
2348
|
+
const response = typeof identifier === "number" ? await context.wordpress.woocommerce.store.products.retrieve({ params: { id: identifier } }, { searchParams: embeds }) : await context.wordpress.woocommerce.store.products.retrieveBySlug({ params: { slug: identifier } }, { searchParams: embeds });
|
|
2346
2349
|
if (response.error) switch (response.error.code) {
|
|
2347
2350
|
case "woocommerce_rest_product_invalid_id":
|
|
2348
2351
|
case "woocommerce_rest_product_invalid_slug": throw errors.PRODUCT_NOT_FOUND({ message: response.error.message });
|
|
@@ -2366,10 +2369,7 @@ const PRODUCT_PROCEDURES = {
|
|
|
2366
2369
|
const searchParams = serializeProductListInput(input.query);
|
|
2367
2370
|
const includeRecommendations = input.query?.recommendations ?? false;
|
|
2368
2371
|
const embeds = includeRecommendations ? { _embed: PRODUCT_EMBEDS } : {};
|
|
2369
|
-
const response = await context.wordpress.woocommerce.store.products.list({
|
|
2370
|
-
...searchParams,
|
|
2371
|
-
...embeds
|
|
2372
|
-
});
|
|
2372
|
+
const response = await context.wordpress.woocommerce.store.products.list({ query: searchParams }, { searchParams: embeds });
|
|
2373
2373
|
if (response.error) switch (response.error.code) {
|
|
2374
2374
|
default:
|
|
2375
2375
|
context.logger.error("List products unhandled error", response.error, { code: response.error.code });
|
|
@@ -2393,7 +2393,7 @@ const PRODUCT_PROCEDURES = {
|
|
|
2393
2393
|
output: ProductFilters.nullable()
|
|
2394
2394
|
}, async ({ context, errors, input }) => {
|
|
2395
2395
|
const searchParams = serializeProductListInput(input.query);
|
|
2396
|
-
const response = await context.wordpress.woocommerce.store.products.collectionData({
|
|
2396
|
+
const response = await context.wordpress.woocommerce.store.products.collectionData.retrieve({ query: {
|
|
2397
2397
|
...searchParams,
|
|
2398
2398
|
calculate_price_range: true,
|
|
2399
2399
|
calculate_rating_counts: input.query?.ratingCounts,
|
|
@@ -2403,7 +2403,7 @@ const PRODUCT_PROCEDURES = {
|
|
|
2403
2403
|
taxonomy: item.taxonomy,
|
|
2404
2404
|
query_type: item.operator
|
|
2405
2405
|
}))
|
|
2406
|
-
});
|
|
2406
|
+
} });
|
|
2407
2407
|
if (response.error) switch (response.error.code) {
|
|
2408
2408
|
default:
|
|
2409
2409
|
context.logger.error("Filter products unhandled error", response.error, { code: response.error.code });
|
|
@@ -2421,14 +2421,14 @@ function woocommerce() {
|
|
|
2421
2421
|
requires: {
|
|
2422
2422
|
plugins: [{
|
|
2423
2423
|
name: "kizlo-woocommerce",
|
|
2424
|
-
version: "0.
|
|
2424
|
+
version: "0.10.0"
|
|
2425
2425
|
}],
|
|
2426
2426
|
endpoints: [
|
|
2427
2427
|
"woocommerce.customers",
|
|
2428
2428
|
"woocommerce.products",
|
|
2429
2429
|
"woocommerce.store.cart",
|
|
2430
2430
|
"woocommerce.store.checkout",
|
|
2431
|
-
"woocommerce.store.
|
|
2431
|
+
"woocommerce.store.order",
|
|
2432
2432
|
"woocommerce.store.products"
|
|
2433
2433
|
]
|
|
2434
2434
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizlo/woocommerce",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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.
|
|
52
|
+
"@kizlo/shared": "0.10.0",
|
|
53
53
|
"jose": "6.1.0",
|
|
54
54
|
"zod": "^4.3.6"
|
|
55
55
|
},
|