@jay-framework/wix-cart 0.25.0 → 0.25.1
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.
|
@@ -306,6 +306,8 @@ interface AddToCartOptions {
|
|
|
306
306
|
modifiers?: Record<string, string>;
|
|
307
307
|
/** Product slug for building the correct product page URL in cart */
|
|
308
308
|
productSlug?: string;
|
|
309
|
+
/** Buy an out-of-stock variant as a pre-order (without it the cart line is NOT_AVAILABLE, quantity 0) */
|
|
310
|
+
preOrderRequested?: boolean;
|
|
309
311
|
}
|
|
310
312
|
/**
|
|
311
313
|
* Client-side Wix Cart context interface.
|
package/dist/index.client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AddToCartOptions, q as CartIndicatorState, n as CartLineItem, C as CartOperationResult, l as CartState, o as CartSummary, R as ReactiveCartIndicator, b as WIX_CART_CONTEXT, c as WixCartContext, r as cartIndicator, s as cartPage, u as init, t as miniCart } from './index.client-
|
|
1
|
+
export { A as AddToCartOptions, q as CartIndicatorState, n as CartLineItem, C as CartOperationResult, l as CartState, o as CartSummary, R as ReactiveCartIndicator, b as WIX_CART_CONTEXT, c as WixCartContext, r as cartIndicator, s as cartPage, u as init, t as miniCart } from './index.client-C5htoaJ2.js';
|
|
2
2
|
import '@jay-framework/runtime';
|
|
3
3
|
import '@jay-framework/reactive';
|
|
4
4
|
import '@wix/sdk';
|
package/dist/index.client.js
CHANGED
|
@@ -59,6 +59,22 @@ async function createRedirectSession(client, options) {
|
|
|
59
59
|
body: options
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
+
const WIX_STORES_APP_ID = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
|
|
63
|
+
function buildAddToCartLineItem(productId, quantity, options) {
|
|
64
|
+
const catalogOptions = {};
|
|
65
|
+
if (options?.variantId) catalogOptions.variantId = options.variantId;
|
|
66
|
+
if (options?.modifiers) catalogOptions.options = options.modifiers;
|
|
67
|
+
if (options?.customTextFields) catalogOptions.customTextFields = options.customTextFields;
|
|
68
|
+
if (options?.preOrderRequested) catalogOptions.preOrderRequested = true;
|
|
69
|
+
return {
|
|
70
|
+
catalogReference: {
|
|
71
|
+
catalogItemId: productId,
|
|
72
|
+
appId: WIX_STORES_APP_ID,
|
|
73
|
+
...Object.keys(catalogOptions).length > 0 ? { options: catalogOptions } : {}
|
|
74
|
+
},
|
|
75
|
+
quantity
|
|
76
|
+
};
|
|
77
|
+
}
|
|
62
78
|
function stripWixMediaResize(url) {
|
|
63
79
|
return url.replace(/\/v1\/(?:fit|fill|crop)\/[^/]+\/file\.\w+$/, "");
|
|
64
80
|
}
|
|
@@ -309,7 +325,6 @@ function mapEstimateTotalsToState(estimate) {
|
|
|
309
325
|
hasAppliedCoupon: !!appliedCoupon
|
|
310
326
|
};
|
|
311
327
|
}
|
|
312
|
-
const WIX_STORES_APP_ID = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
|
|
313
328
|
const WIX_CART_CONTEXT = createJayContext("wix:cart");
|
|
314
329
|
function provideWixCartContext(thankYouUrl = "/thank-you") {
|
|
315
330
|
const wixClientContext = useGlobalContext(WIX_CLIENT_CONTEXT);
|
|
@@ -336,19 +351,7 @@ function provideWixCartContext(thankYouUrl = "/thank-you") {
|
|
|
336
351
|
}
|
|
337
352
|
async function addToCart(productId, quantity = 1, options) {
|
|
338
353
|
console.log(`[WixCart] Adding to cart: ${productId} x ${quantity}`, options);
|
|
339
|
-
const
|
|
340
|
-
if (options?.variantId) catalogOptions.variantId = options.variantId;
|
|
341
|
-
if (options?.modifiers) catalogOptions.options = options.modifiers;
|
|
342
|
-
if (options?.customTextFields)
|
|
343
|
-
catalogOptions.customTextFields = options.customTextFields;
|
|
344
|
-
const lineItem = {
|
|
345
|
-
catalogReference: {
|
|
346
|
-
catalogItemId: productId,
|
|
347
|
-
appId: WIX_STORES_APP_ID,
|
|
348
|
-
...Object.keys(catalogOptions).length > 0 ? { options: catalogOptions } : {}
|
|
349
|
-
},
|
|
350
|
-
quantity
|
|
351
|
-
};
|
|
354
|
+
const lineItem = buildAddToCartLineItem(productId, quantity, options);
|
|
352
355
|
const result = await addToCurrentCart(wixClient, [lineItem]);
|
|
353
356
|
updateIndicatorFromCart(result.cart ?? null);
|
|
354
357
|
onItemAddedToCart.emit();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WixClient } from '@wix/sdk';
|
|
2
|
-
import { W as WixCartService } from './index.client-
|
|
3
|
-
export { A as AddToCartOptions, q as CartIndicatorState, n as CartLineItem, C as CartOperationResult, l as CartState, o as CartSummary, R as ReactiveCartIndicator, b as WIX_CART_CONTEXT, a as WIX_CART_SERVICE, c as WixCartContext, d as WixCartInitData, r as cartIndicator, s as cartPage, j as estimateCurrentCartTotalsOrNull, i as getCurrentCartOrNull, h as getEmptyCartState, u as init, e as mapCartSummary, g as mapCartToIndicator, f as mapCartToState, k as mapEstimateTotalsToState, m as mapLineItem, t as miniCart, p as provideWixCartContext } from './index.client-
|
|
2
|
+
import { W as WixCartService } from './index.client-C5htoaJ2.js';
|
|
3
|
+
export { A as AddToCartOptions, q as CartIndicatorState, n as CartLineItem, C as CartOperationResult, l as CartState, o as CartSummary, R as ReactiveCartIndicator, b as WIX_CART_CONTEXT, a as WIX_CART_SERVICE, c as WixCartContext, d as WixCartInitData, r as cartIndicator, s as cartPage, j as estimateCurrentCartTotalsOrNull, i as getCurrentCartOrNull, h as getEmptyCartState, u as init, e as mapCartSummary, g as mapCartToIndicator, f as mapCartToState, k as mapEstimateTotalsToState, m as mapLineItem, t as miniCart, p as provideWixCartContext } from './index.client-C5htoaJ2.js';
|
|
4
4
|
import '@jay-framework/runtime';
|
|
5
5
|
import '@jay-framework/reactive';
|
|
6
6
|
import '@jay-framework/fullstack-component';
|
package/dist/index.js
CHANGED
|
@@ -68,6 +68,22 @@ async function createRedirectSession(client, options) {
|
|
|
68
68
|
body: options
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
+
const WIX_STORES_APP_ID = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
|
|
72
|
+
function buildAddToCartLineItem(productId, quantity, options) {
|
|
73
|
+
const catalogOptions = {};
|
|
74
|
+
if (options?.variantId) catalogOptions.variantId = options.variantId;
|
|
75
|
+
if (options?.modifiers) catalogOptions.options = options.modifiers;
|
|
76
|
+
if (options?.customTextFields) catalogOptions.customTextFields = options.customTextFields;
|
|
77
|
+
if (options?.preOrderRequested) catalogOptions.preOrderRequested = true;
|
|
78
|
+
return {
|
|
79
|
+
catalogReference: {
|
|
80
|
+
catalogItemId: productId,
|
|
81
|
+
appId: WIX_STORES_APP_ID,
|
|
82
|
+
...Object.keys(catalogOptions).length > 0 ? { options: catalogOptions } : {}
|
|
83
|
+
},
|
|
84
|
+
quantity
|
|
85
|
+
};
|
|
86
|
+
}
|
|
71
87
|
function stripWixMediaResize(url) {
|
|
72
88
|
return url.replace(/\/v1\/(?:fit|fill|crop)\/[^/]+\/file\.\w+$/, "");
|
|
73
89
|
}
|
|
@@ -318,7 +334,6 @@ function mapEstimateTotalsToState(estimate) {
|
|
|
318
334
|
hasAppliedCoupon: !!appliedCoupon
|
|
319
335
|
};
|
|
320
336
|
}
|
|
321
|
-
const WIX_STORES_APP_ID = "215238eb-22a5-4c36-9e7b-e7c08025e04e";
|
|
322
337
|
const WIX_CART_CONTEXT = createJayContext("wix:cart");
|
|
323
338
|
function provideWixCartContext(thankYouUrl = "/thank-you") {
|
|
324
339
|
const wixClientContext = useGlobalContext(WIX_CLIENT_CONTEXT);
|
|
@@ -345,19 +360,7 @@ function provideWixCartContext(thankYouUrl = "/thank-you") {
|
|
|
345
360
|
}
|
|
346
361
|
async function addToCart(productId, quantity = 1, options) {
|
|
347
362
|
console.log(`[WixCart] Adding to cart: ${productId} x ${quantity}`, options);
|
|
348
|
-
const
|
|
349
|
-
if (options?.variantId) catalogOptions.variantId = options.variantId;
|
|
350
|
-
if (options?.modifiers) catalogOptions.options = options.modifiers;
|
|
351
|
-
if (options?.customTextFields)
|
|
352
|
-
catalogOptions.customTextFields = options.customTextFields;
|
|
353
|
-
const lineItem = {
|
|
354
|
-
catalogReference: {
|
|
355
|
-
catalogItemId: productId,
|
|
356
|
-
appId: WIX_STORES_APP_ID,
|
|
357
|
-
...Object.keys(catalogOptions).length > 0 ? { options: catalogOptions } : {}
|
|
358
|
-
},
|
|
359
|
-
quantity
|
|
360
|
-
};
|
|
363
|
+
const lineItem = buildAddToCartLineItem(productId, quantity, options);
|
|
361
364
|
const result = await addToCurrentCart(wixClient, [lineItem]);
|
|
362
365
|
updateIndicatorFromCart(result.cart ?? null);
|
|
363
366
|
onItemAddedToCart.emit();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jay-framework/wix-cart",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Wix Cart/Ecom shared package for Jay Framework",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,27 +34,27 @@
|
|
|
34
34
|
"build:check-types": "tsc",
|
|
35
35
|
"clean": "rimraf dist",
|
|
36
36
|
"confirm": "npm run clean && npm run build && npm run test",
|
|
37
|
-
"test": "
|
|
37
|
+
"test": "vitest run"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@jay-framework/component": "^0.25.
|
|
41
|
-
"@jay-framework/fullstack-component": "^0.25.
|
|
42
|
-
"@jay-framework/reactive": "^0.25.
|
|
43
|
-
"@jay-framework/runtime": "^0.25.
|
|
44
|
-
"@jay-framework/secure": "^0.25.
|
|
45
|
-
"@jay-framework/stack-client-runtime": "^0.25.
|
|
46
|
-
"@jay-framework/stack-server-runtime": "^0.25.
|
|
47
|
-
"@jay-framework/wix-server-client": "^0.25.
|
|
48
|
-
"@jay-framework/wix-utils": "^0.25.
|
|
40
|
+
"@jay-framework/component": "^0.25.1",
|
|
41
|
+
"@jay-framework/fullstack-component": "^0.25.1",
|
|
42
|
+
"@jay-framework/reactive": "^0.25.1",
|
|
43
|
+
"@jay-framework/runtime": "^0.25.1",
|
|
44
|
+
"@jay-framework/secure": "^0.25.1",
|
|
45
|
+
"@jay-framework/stack-client-runtime": "^0.25.1",
|
|
46
|
+
"@jay-framework/stack-server-runtime": "^0.25.1",
|
|
47
|
+
"@jay-framework/wix-server-client": "^0.25.1",
|
|
48
|
+
"@jay-framework/wix-utils": "^0.25.1",
|
|
49
49
|
"@wix/sdk": "^1.21.5"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@babel/core": "^7.23.7",
|
|
53
53
|
"@babel/preset-env": "^7.23.8",
|
|
54
54
|
"@babel/preset-typescript": "^7.23.3",
|
|
55
|
-
"@jay-framework/compiler-jay-stack": "^0.25.
|
|
56
|
-
"@jay-framework/jay-cli": "^0.25.
|
|
57
|
-
"@jay-framework/vite-plugin": "^0.25.
|
|
55
|
+
"@jay-framework/compiler-jay-stack": "^0.25.1",
|
|
56
|
+
"@jay-framework/jay-cli": "^0.25.1",
|
|
57
|
+
"@jay-framework/vite-plugin": "^0.25.1",
|
|
58
58
|
"@jay-framework/wix-dev-environment": "^0.6.12",
|
|
59
59
|
"nodemon": "^3.0.3",
|
|
60
60
|
"rimraf": "^5.0.5",
|