@storepecker/storefront-core 2.4.1 → 2.5.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/api/index.cjs +50 -42
- package/dist/api/index.d.cts +11 -4
- package/dist/api/index.d.ts +11 -4
- package/dist/api/index.js +2 -2
- package/dist/{cart-y-7RPmnQ.d.ts → cart-CLf2ljxd.d.ts} +21 -0
- package/dist/{cart-kJoawc_Z.d.cts → cart-CuLMWnfy.d.cts} +21 -0
- package/dist/checkout/index.cjs +22 -22
- package/dist/checkout/index.d.cts +1 -1
- package/dist/checkout/index.d.ts +1 -1
- package/dist/checkout/index.js +2 -2
- package/dist/{chunk-TTIQRDHX.cjs → chunk-23YAZNVF.cjs} +37 -18
- package/dist/{chunk-7UK3E7SL.cjs → chunk-DXQX7ZIL.cjs} +9 -2
- package/dist/{chunk-Y2CPMT34.cjs → chunk-MTSMQAZR.cjs} +11 -3
- package/dist/{chunk-UVU7H4E6.js → chunk-S3ZZ3ZA7.js} +9 -3
- package/dist/{chunk-33TWVRZE.cjs → chunk-TLNCCSTQ.cjs} +6 -6
- package/dist/{chunk-HUIT4JCR.js → chunk-VETLYY7W.js} +1 -1
- package/dist/{chunk-JRYWZMNT.js → chunk-VZAIAQZJ.js} +33 -14
- package/dist/{chunk-U25T7M6S.js → chunk-XURYZRER.js} +11 -4
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.ts +2 -2
- package/dist/components/theme-data-initializer.d.cts +2 -2
- package/dist/components/theme-data-initializer.d.ts +2 -2
- package/dist/hooks/index.cjs +22 -21
- package/dist/hooks/index.d.cts +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +6 -5
- package/dist/models/index.d.cts +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/{pixelEvents-C1rFPOwb.d.cts → pixelEvents-CXViXGtV.d.cts} +1 -1
- package/dist/{pixelEvents-Bo-VjAx8.d.ts → pixelEvents-LqK0Ltr_.d.ts} +1 -1
- package/dist/store/index.cjs +8 -8
- package/dist/store/index.d.cts +5 -4
- package/dist/store/index.d.ts +5 -4
- package/dist/store/index.js +3 -3
- package/dist/utils/index.d.cts +3 -3
- package/dist/utils/index.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkMTSMQAZR_cjs = require('./chunk-MTSMQAZR.cjs');
|
|
4
4
|
var chunkSMHJRNCR_cjs = require('./chunk-SMHJRNCR.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkDXQX7ZIL_cjs = require('./chunk-DXQX7ZIL.cjs');
|
|
6
6
|
var chunkBBRXE57K_cjs = require('./chunk-BBRXE57K.cjs');
|
|
7
7
|
var chunkNE3ZHELZ_cjs = require('./chunk-NE3ZHELZ.cjs');
|
|
8
8
|
var zustand = require('zustand');
|
|
@@ -10,33 +10,42 @@ var typescriptCookie = require('typescript-cookie');
|
|
|
10
10
|
|
|
11
11
|
var initialState = {
|
|
12
12
|
cart: null,
|
|
13
|
+
total_quantity: 0,
|
|
13
14
|
status: "idle" /* IDLE */
|
|
14
15
|
};
|
|
15
16
|
var useCartStore = zustand.create((set) => ({
|
|
16
17
|
...initialState,
|
|
17
|
-
setCart: (cart) => set({ cart, status: "idle" /* IDLE */ }),
|
|
18
|
+
setCart: (cart) => set({ cart, total_quantity: cart.total_quantity, status: "idle" /* IDLE */ }),
|
|
18
19
|
resetCart: () => set(initialState),
|
|
19
20
|
resetCartCount: () => set((state) => {
|
|
20
|
-
if (!state.cart) return state;
|
|
21
|
-
return { cart: { ...state.cart, total_quantity: 0 } };
|
|
21
|
+
if (!state.cart) return { ...state, total_quantity: 0 };
|
|
22
|
+
return { cart: { ...state.cart, total_quantity: 0 }, total_quantity: 0 };
|
|
22
23
|
}),
|
|
23
|
-
|
|
24
|
+
fetchCartQuantity: async () => {
|
|
25
|
+
try {
|
|
26
|
+
const { total_quantity } = await chunkMTSMQAZR_cjs.getCartItemQuantity();
|
|
27
|
+
set({ total_quantity });
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error("Failed to fetch cart quantity", error);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
syncCart: async (addressId, shippingOptionId) => {
|
|
24
33
|
set({ status: "loading" /* LOADING */ });
|
|
25
34
|
try {
|
|
26
|
-
const response = await
|
|
35
|
+
const response = await chunkMTSMQAZR_cjs.getCart("/customer/cart/", addressId, shippingOptionId);
|
|
27
36
|
if (response) {
|
|
28
|
-
set({ cart: response, status: "idle" /* IDLE */ });
|
|
37
|
+
set({ cart: response, total_quantity: response.total_quantity, status: "idle" /* IDLE */ });
|
|
29
38
|
}
|
|
30
39
|
} catch {
|
|
31
40
|
set({ status: "idle" /* IDLE */ });
|
|
32
41
|
}
|
|
33
42
|
},
|
|
34
|
-
fetchCart: async (addressId) => {
|
|
43
|
+
fetchCart: async (addressId, shippingOptionId) => {
|
|
35
44
|
set({ status: "loading" /* LOADING */ });
|
|
36
45
|
try {
|
|
37
|
-
const response = await
|
|
46
|
+
const response = await chunkMTSMQAZR_cjs.getCart("/customer/cart/", addressId, shippingOptionId);
|
|
38
47
|
if (response) {
|
|
39
|
-
set({ cart: response, status: "idle" /* IDLE */ });
|
|
48
|
+
set({ cart: response, total_quantity: response.total_quantity, status: "idle" /* IDLE */ });
|
|
40
49
|
}
|
|
41
50
|
} catch {
|
|
42
51
|
set({ status: "idle" /* IDLE */ });
|
|
@@ -46,7 +55,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
46
55
|
set({ status: "loading" /* LOADING */ });
|
|
47
56
|
try {
|
|
48
57
|
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
49
|
-
await
|
|
58
|
+
await chunkMTSMQAZR_cjs.addToCart(items, customizationInputs);
|
|
50
59
|
await useCartStore.getState().syncCart(addressId);
|
|
51
60
|
} else {
|
|
52
61
|
const cart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
@@ -61,7 +70,9 @@ var useCartStore = zustand.create((set) => ({
|
|
|
61
70
|
});
|
|
62
71
|
}
|
|
63
72
|
const updatedCart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
64
|
-
if (updatedCart)
|
|
73
|
+
if (updatedCart) {
|
|
74
|
+
set({ cart: updatedCart, total_quantity: updatedCart.total_quantity });
|
|
75
|
+
}
|
|
65
76
|
}
|
|
66
77
|
} catch {
|
|
67
78
|
} finally {
|
|
@@ -72,7 +83,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
72
83
|
set({ status: "loading" /* LOADING */ });
|
|
73
84
|
try {
|
|
74
85
|
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
75
|
-
await
|
|
86
|
+
await chunkMTSMQAZR_cjs.removeFromCart(items);
|
|
76
87
|
await useCartStore.getState().syncCart(addressId);
|
|
77
88
|
} else {
|
|
78
89
|
const cart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
@@ -86,7 +97,10 @@ var useCartStore = zustand.create((set) => ({
|
|
|
86
97
|
}
|
|
87
98
|
const updatedCart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
88
99
|
if (updatedCart) {
|
|
89
|
-
set({
|
|
100
|
+
set({
|
|
101
|
+
cart: updatedCart,
|
|
102
|
+
total_quantity: updatedCart.total_quantity
|
|
103
|
+
});
|
|
90
104
|
} else {
|
|
91
105
|
set(initialState);
|
|
92
106
|
}
|
|
@@ -100,7 +114,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
100
114
|
set({ status: "loading" /* LOADING */ });
|
|
101
115
|
try {
|
|
102
116
|
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
103
|
-
await
|
|
117
|
+
await chunkMTSMQAZR_cjs.updateCart(items);
|
|
104
118
|
await useCartStore.getState().syncCart(addressId);
|
|
105
119
|
} else {
|
|
106
120
|
const cart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
@@ -113,7 +127,12 @@ var useCartStore = zustand.create((set) => ({
|
|
|
113
127
|
});
|
|
114
128
|
}
|
|
115
129
|
const updatedCart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
116
|
-
if (updatedCart)
|
|
130
|
+
if (updatedCart) {
|
|
131
|
+
set({
|
|
132
|
+
cart: updatedCart,
|
|
133
|
+
total_quantity: updatedCart.total_quantity
|
|
134
|
+
});
|
|
135
|
+
}
|
|
117
136
|
}
|
|
118
137
|
} catch {
|
|
119
138
|
} finally {
|
|
@@ -123,7 +142,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
123
142
|
updateCustomization: async (customizationInputs) => {
|
|
124
143
|
set({ status: "loading" /* LOADING */ });
|
|
125
144
|
try {
|
|
126
|
-
await
|
|
145
|
+
await chunkDXQX7ZIL_cjs.updateOrderCustomization({ customization_inputs: customizationInputs });
|
|
127
146
|
} catch {
|
|
128
147
|
} finally {
|
|
129
148
|
set({ status: "idle" /* IDLE */ });
|
|
@@ -18,6 +18,11 @@ async function getOrderDetailsByNumber(orderNumber) {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
async function getOrderDetailsByRef(orderRef) {
|
|
21
|
+
return chunkECHV2JSY_cjs.http_service_default.get("/customer/order/", {
|
|
22
|
+
params: { order_ref: orderRef }
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async function getOrderDetailsByRefV2(orderRef) {
|
|
21
26
|
return chunkECHV2JSY_cjs.http_service_default.get("/customer/order-detail/", {
|
|
22
27
|
params: { order_ref: orderRef }
|
|
23
28
|
});
|
|
@@ -27,11 +32,12 @@ async function getPublicOrderDetailsByNumber(orderNumber) {
|
|
|
27
32
|
params: { order_number: orderNumber }
|
|
28
33
|
});
|
|
29
34
|
}
|
|
30
|
-
async function placeOrder(address_id, redirect, isCod, stripeRedirect, tabbyRedirect) {
|
|
35
|
+
async function placeOrder(address_id, redirect, isCod, shipping_option_id, stripeRedirect, tabbyRedirect) {
|
|
31
36
|
return chunkECHV2JSY_cjs.http_service_default.post("/customer/order/", {
|
|
32
37
|
address_id,
|
|
33
38
|
phonepe_redirect_url: redirect,
|
|
34
39
|
is_cod: isCod,
|
|
40
|
+
shipping_option_id,
|
|
35
41
|
stripe_redirect_url: stripeRedirect,
|
|
36
42
|
tabby_redirect_url: tabbyRedirect
|
|
37
43
|
});
|
|
@@ -55,7 +61,7 @@ async function razorpayOrderSuccess(orderDetails) {
|
|
|
55
61
|
return chunkECHV2JSY_cjs.http_service_default.post("/payment/razorpay-order-success/", orderDetails);
|
|
56
62
|
}
|
|
57
63
|
async function razorpayOrderFail(orderDetails) {
|
|
58
|
-
return chunkECHV2JSY_cjs.http_service_default.post("/payment/razorpay-order-
|
|
64
|
+
return chunkECHV2JSY_cjs.http_service_default.post("/payment/razorpay-order-failure/", orderDetails);
|
|
59
65
|
}
|
|
60
66
|
async function phonepePublicOrderSuccess(orderDetails) {
|
|
61
67
|
return chunkECHV2JSY_cjs.http_service_default.post("/payment/public-phonepe-order-success/", orderDetails);
|
|
@@ -117,6 +123,7 @@ exports.checkPhonepePaymentStatus = checkPhonepePaymentStatus;
|
|
|
117
123
|
exports.getOrderDetails = getOrderDetails;
|
|
118
124
|
exports.getOrderDetailsByNumber = getOrderDetailsByNumber;
|
|
119
125
|
exports.getOrderDetailsByRef = getOrderDetailsByRef;
|
|
126
|
+
exports.getOrderDetailsByRefV2 = getOrderDetailsByRefV2;
|
|
120
127
|
exports.getOrders = getOrders;
|
|
121
128
|
exports.getPublicOrderDetailsByNumber = getPublicOrderDetailsByNumber;
|
|
122
129
|
exports.getStripePaymentStatus = getStripePaymentStatus;
|
|
@@ -5,9 +5,9 @@ var chunkECHV2JSY_cjs = require('./chunk-ECHV2JSY.cjs');
|
|
|
5
5
|
var chunkBBRXE57K_cjs = require('./chunk-BBRXE57K.cjs');
|
|
6
6
|
|
|
7
7
|
// src/api/cart.ts
|
|
8
|
-
async function getCart(url, addressId) {
|
|
8
|
+
async function getCart(url, addressId, shippingOptionId) {
|
|
9
9
|
const localCart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
10
|
-
return chunkBBRXE57K_cjs.auth_default.getUserDetails() ? (await chunkECHV2JSY_cjs.http_service_default.get(url, { params: { address_id: addressId } })).data : localCart || {
|
|
10
|
+
return chunkBBRXE57K_cjs.auth_default.getUserDetails() ? (await chunkECHV2JSY_cjs.http_service_default.get(url, { params: { address_id: addressId, shipping_option_id: shippingOptionId } })).data : localCart || {
|
|
11
11
|
product_variants: [],
|
|
12
12
|
total_amount: 0,
|
|
13
13
|
total_quantity: 0,
|
|
@@ -20,9 +20,16 @@ async function getCart(url, addressId) {
|
|
|
20
20
|
variant_discounts: {},
|
|
21
21
|
total_shipping: 0,
|
|
22
22
|
total_tax_amount: 0,
|
|
23
|
-
applied_coupon: {}
|
|
23
|
+
applied_coupon: {},
|
|
24
|
+
shipping_options: [],
|
|
25
|
+
selected_shipping_option_id: null,
|
|
26
|
+
selected_address_id: null
|
|
24
27
|
};
|
|
25
28
|
}
|
|
29
|
+
async function getCartItemQuantity() {
|
|
30
|
+
const localCart = chunkSMHJRNCR_cjs.cart_default.get();
|
|
31
|
+
return chunkBBRXE57K_cjs.auth_default.getUserDetails() ? (await chunkECHV2JSY_cjs.http_service_default.get("/customer/cart/quantity/")).data : { total_quantity: localCart?.total_quantity || 0 };
|
|
32
|
+
}
|
|
26
33
|
async function addToCart(product, customizationInputs) {
|
|
27
34
|
return chunkECHV2JSY_cjs.http_service_default.post("/customer/cart/", {
|
|
28
35
|
action: "add",
|
|
@@ -117,6 +124,7 @@ async function removeFromWishlist(product_variants) {
|
|
|
117
124
|
exports.addToCart = addToCart;
|
|
118
125
|
exports.addWishlist = addWishlist;
|
|
119
126
|
exports.getCart = getCart;
|
|
127
|
+
exports.getCartItemQuantity = getCartItemQuantity;
|
|
120
128
|
exports.getCategories = getCategories;
|
|
121
129
|
exports.getDigitalProductDownloadLink = getDigitalProductDownloadLink;
|
|
122
130
|
exports.getProductCategories = getProductCategories;
|
|
@@ -16,6 +16,11 @@ async function getOrderDetailsByNumber(orderNumber) {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
async function getOrderDetailsByRef(orderRef) {
|
|
19
|
+
return http_service_default.get("/customer/order/", {
|
|
20
|
+
params: { order_ref: orderRef }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async function getOrderDetailsByRefV2(orderRef) {
|
|
19
24
|
return http_service_default.get("/customer/order-detail/", {
|
|
20
25
|
params: { order_ref: orderRef }
|
|
21
26
|
});
|
|
@@ -25,11 +30,12 @@ async function getPublicOrderDetailsByNumber(orderNumber) {
|
|
|
25
30
|
params: { order_number: orderNumber }
|
|
26
31
|
});
|
|
27
32
|
}
|
|
28
|
-
async function placeOrder(address_id, redirect, isCod, stripeRedirect, tabbyRedirect) {
|
|
33
|
+
async function placeOrder(address_id, redirect, isCod, shipping_option_id, stripeRedirect, tabbyRedirect) {
|
|
29
34
|
return http_service_default.post("/customer/order/", {
|
|
30
35
|
address_id,
|
|
31
36
|
phonepe_redirect_url: redirect,
|
|
32
37
|
is_cod: isCod,
|
|
38
|
+
shipping_option_id,
|
|
33
39
|
stripe_redirect_url: stripeRedirect,
|
|
34
40
|
tabby_redirect_url: tabbyRedirect
|
|
35
41
|
});
|
|
@@ -53,7 +59,7 @@ async function razorpayOrderSuccess(orderDetails) {
|
|
|
53
59
|
return http_service_default.post("/payment/razorpay-order-success/", orderDetails);
|
|
54
60
|
}
|
|
55
61
|
async function razorpayOrderFail(orderDetails) {
|
|
56
|
-
return http_service_default.post("/payment/razorpay-order-
|
|
62
|
+
return http_service_default.post("/payment/razorpay-order-failure/", orderDetails);
|
|
57
63
|
}
|
|
58
64
|
async function phonepePublicOrderSuccess(orderDetails) {
|
|
59
65
|
return http_service_default.post("/payment/public-phonepe-order-success/", orderDetails);
|
|
@@ -111,4 +117,4 @@ async function verifyTabbyPayment(orderNumber) {
|
|
|
111
117
|
});
|
|
112
118
|
}
|
|
113
119
|
|
|
114
|
-
export { checkPhonepePaymentStatus, getOrderDetails, getOrderDetailsByNumber, getOrderDetailsByRef, getOrders, getPublicOrderDetailsByNumber, getStripePaymentStatus, getStripePaymentStatusPublic, makeCODOrder, phonepeOrderSuccess, phonepePublicOrderSuccess, placeOrder, publicMakeCODOrder, publicPlaceOrder, razorpayOrderFail, razorpayOrderSuccess, razorpayPublicOrderSuccess, stripeOrderFail, stripeOrderSuccess, stripePublicOrderSuccess, updateOrder, updateOrderCustomization, uploadCustomizationImage, verifyTabbyPayment };
|
|
120
|
+
export { checkPhonepePaymentStatus, getOrderDetails, getOrderDetailsByNumber, getOrderDetailsByRef, getOrderDetailsByRefV2, getOrders, getPublicOrderDetailsByNumber, getStripePaymentStatus, getStripePaymentStatusPublic, makeCODOrder, phonepeOrderSuccess, phonepePublicOrderSuccess, placeOrder, publicMakeCODOrder, publicPlaceOrder, razorpayOrderFail, razorpayOrderSuccess, razorpayPublicOrderSuccess, stripeOrderFail, stripeOrderSuccess, stripePublicOrderSuccess, updateOrder, updateOrderCustomization, uploadCustomizationImage, verifyTabbyPayment };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkXFOUNOKO_cjs = require('./chunk-XFOUNOKO.cjs');
|
|
4
4
|
var chunkK44JZ5NL_cjs = require('./chunk-K44JZ5NL.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkDXQX7ZIL_cjs = require('./chunk-DXQX7ZIL.cjs');
|
|
6
6
|
var chunkN3CTXRFT_cjs = require('./chunk-N3CTXRFT.cjs');
|
|
7
7
|
var axios = require('axios');
|
|
8
8
|
|
|
@@ -66,7 +66,7 @@ function openRazorpayCheckout(order, callbacks) {
|
|
|
66
66
|
async function handleRazorpaySuccess(data, order, callbacks) {
|
|
67
67
|
try {
|
|
68
68
|
callbacks.onPaymentStart?.();
|
|
69
|
-
await
|
|
69
|
+
await chunkDXQX7ZIL_cjs.razorpayOrderSuccess(data);
|
|
70
70
|
chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
|
|
71
71
|
chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
|
|
72
72
|
callbacks.onCartReset();
|
|
@@ -79,7 +79,7 @@ async function handleRazorpaySuccess(data, order, callbacks) {
|
|
|
79
79
|
}
|
|
80
80
|
async function handleRazorpayFail(order, callbacks) {
|
|
81
81
|
try {
|
|
82
|
-
await
|
|
82
|
+
await chunkDXQX7ZIL_cjs.razorpayOrderFail({
|
|
83
83
|
order_id: order.id,
|
|
84
84
|
razorpay_order_id: order.razorpay_order_id
|
|
85
85
|
});
|
|
@@ -111,9 +111,9 @@ async function handleCODPayment(order, callbacks, options) {
|
|
|
111
111
|
callbacks.onPaymentStart?.();
|
|
112
112
|
chunkK44JZ5NL_cjs.pixelEvents.initiateCheckout(order, "cod");
|
|
113
113
|
if (options?.isPublic) {
|
|
114
|
-
await
|
|
114
|
+
await chunkDXQX7ZIL_cjs.publicMakeCODOrder(order.order_number);
|
|
115
115
|
} else {
|
|
116
|
-
await
|
|
116
|
+
await chunkDXQX7ZIL_cjs.makeCODOrder(order.id);
|
|
117
117
|
}
|
|
118
118
|
chunkK44JZ5NL_cjs.pixelEvents.purchase(order);
|
|
119
119
|
chunkK44JZ5NL_cjs.pixelEvents.checkoutCompleted(order);
|
|
@@ -141,7 +141,7 @@ function handleStripePayment(order, callbacks) {
|
|
|
141
141
|
async function handleStripeSuccess(order, paymentIntentId, callbacks) {
|
|
142
142
|
try {
|
|
143
143
|
callbacks.onPaymentStart?.();
|
|
144
|
-
await
|
|
144
|
+
await chunkDXQX7ZIL_cjs.stripeOrderSuccess({
|
|
145
145
|
order_id: order.id,
|
|
146
146
|
payment_intent_id: paymentIntentId
|
|
147
147
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getCoupons, getAppliedCoupon, applyCoupon, removeCoupon } from './chunk-7M5CVYZJ.js';
|
|
2
2
|
import { pixelEvents } from './chunk-WFDKKOO7.js';
|
|
3
|
-
import { razorpayOrderSuccess, razorpayOrderFail, publicMakeCODOrder, makeCODOrder, stripeOrderSuccess } from './chunk-
|
|
3
|
+
import { razorpayOrderSuccess, razorpayOrderFail, publicMakeCODOrder, makeCODOrder, stripeOrderSuccess } from './chunk-S3ZZ3ZA7.js';
|
|
4
4
|
import { getCloudFront } from './chunk-JQMLHRWL.js';
|
|
5
5
|
import { AxiosError } from 'axios';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { updateCart, removeFromCart, addToCart, getCart } from './chunk-
|
|
1
|
+
import { updateCart, removeFromCart, addToCart, getCart, getCartItemQuantity } from './chunk-XURYZRER.js';
|
|
2
2
|
import { cart_default } from './chunk-QAC72HKO.js';
|
|
3
|
-
import { updateOrderCustomization } from './chunk-
|
|
3
|
+
import { updateOrderCustomization } from './chunk-S3ZZ3ZA7.js';
|
|
4
4
|
import { auth_default } from './chunk-WEMNXIRS.js';
|
|
5
5
|
import { USER_CRED_TOKEN, USER_CREDENTIALS } from './chunk-BQ256JKN.js';
|
|
6
6
|
import { create } from 'zustand';
|
|
@@ -8,33 +8,42 @@ import { getCookie } from 'typescript-cookie';
|
|
|
8
8
|
|
|
9
9
|
var initialState = {
|
|
10
10
|
cart: null,
|
|
11
|
+
total_quantity: 0,
|
|
11
12
|
status: "idle" /* IDLE */
|
|
12
13
|
};
|
|
13
14
|
var useCartStore = create((set) => ({
|
|
14
15
|
...initialState,
|
|
15
|
-
setCart: (cart) => set({ cart, status: "idle" /* IDLE */ }),
|
|
16
|
+
setCart: (cart) => set({ cart, total_quantity: cart.total_quantity, status: "idle" /* IDLE */ }),
|
|
16
17
|
resetCart: () => set(initialState),
|
|
17
18
|
resetCartCount: () => set((state) => {
|
|
18
|
-
if (!state.cart) return state;
|
|
19
|
-
return { cart: { ...state.cart, total_quantity: 0 } };
|
|
19
|
+
if (!state.cart) return { ...state, total_quantity: 0 };
|
|
20
|
+
return { cart: { ...state.cart, total_quantity: 0 }, total_quantity: 0 };
|
|
20
21
|
}),
|
|
21
|
-
|
|
22
|
+
fetchCartQuantity: async () => {
|
|
23
|
+
try {
|
|
24
|
+
const { total_quantity } = await getCartItemQuantity();
|
|
25
|
+
set({ total_quantity });
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error("Failed to fetch cart quantity", error);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
syncCart: async (addressId, shippingOptionId) => {
|
|
22
31
|
set({ status: "loading" /* LOADING */ });
|
|
23
32
|
try {
|
|
24
|
-
const response = await getCart("/customer/cart/", addressId);
|
|
33
|
+
const response = await getCart("/customer/cart/", addressId, shippingOptionId);
|
|
25
34
|
if (response) {
|
|
26
|
-
set({ cart: response, status: "idle" /* IDLE */ });
|
|
35
|
+
set({ cart: response, total_quantity: response.total_quantity, status: "idle" /* IDLE */ });
|
|
27
36
|
}
|
|
28
37
|
} catch {
|
|
29
38
|
set({ status: "idle" /* IDLE */ });
|
|
30
39
|
}
|
|
31
40
|
},
|
|
32
|
-
fetchCart: async (addressId) => {
|
|
41
|
+
fetchCart: async (addressId, shippingOptionId) => {
|
|
33
42
|
set({ status: "loading" /* LOADING */ });
|
|
34
43
|
try {
|
|
35
|
-
const response = await getCart("/customer/cart/", addressId);
|
|
44
|
+
const response = await getCart("/customer/cart/", addressId, shippingOptionId);
|
|
36
45
|
if (response) {
|
|
37
|
-
set({ cart: response, status: "idle" /* IDLE */ });
|
|
46
|
+
set({ cart: response, total_quantity: response.total_quantity, status: "idle" /* IDLE */ });
|
|
38
47
|
}
|
|
39
48
|
} catch {
|
|
40
49
|
set({ status: "idle" /* IDLE */ });
|
|
@@ -59,7 +68,9 @@ var useCartStore = create((set) => ({
|
|
|
59
68
|
});
|
|
60
69
|
}
|
|
61
70
|
const updatedCart = cart_default.get();
|
|
62
|
-
if (updatedCart)
|
|
71
|
+
if (updatedCart) {
|
|
72
|
+
set({ cart: updatedCart, total_quantity: updatedCart.total_quantity });
|
|
73
|
+
}
|
|
63
74
|
}
|
|
64
75
|
} catch {
|
|
65
76
|
} finally {
|
|
@@ -84,7 +95,10 @@ var useCartStore = create((set) => ({
|
|
|
84
95
|
}
|
|
85
96
|
const updatedCart = cart_default.get();
|
|
86
97
|
if (updatedCart) {
|
|
87
|
-
set({
|
|
98
|
+
set({
|
|
99
|
+
cart: updatedCart,
|
|
100
|
+
total_quantity: updatedCart.total_quantity
|
|
101
|
+
});
|
|
88
102
|
} else {
|
|
89
103
|
set(initialState);
|
|
90
104
|
}
|
|
@@ -111,7 +125,12 @@ var useCartStore = create((set) => ({
|
|
|
111
125
|
});
|
|
112
126
|
}
|
|
113
127
|
const updatedCart = cart_default.get();
|
|
114
|
-
if (updatedCart)
|
|
128
|
+
if (updatedCart) {
|
|
129
|
+
set({
|
|
130
|
+
cart: updatedCart,
|
|
131
|
+
total_quantity: updatedCart.total_quantity
|
|
132
|
+
});
|
|
133
|
+
}
|
|
115
134
|
}
|
|
116
135
|
} catch {
|
|
117
136
|
} finally {
|
|
@@ -3,9 +3,9 @@ import { http_service_default } from './chunk-3SYYP3XV.js';
|
|
|
3
3
|
import { auth_default } from './chunk-WEMNXIRS.js';
|
|
4
4
|
|
|
5
5
|
// src/api/cart.ts
|
|
6
|
-
async function getCart(url, addressId) {
|
|
6
|
+
async function getCart(url, addressId, shippingOptionId) {
|
|
7
7
|
const localCart = cart_default.get();
|
|
8
|
-
return auth_default.getUserDetails() ? (await http_service_default.get(url, { params: { address_id: addressId } })).data : localCart || {
|
|
8
|
+
return auth_default.getUserDetails() ? (await http_service_default.get(url, { params: { address_id: addressId, shipping_option_id: shippingOptionId } })).data : localCart || {
|
|
9
9
|
product_variants: [],
|
|
10
10
|
total_amount: 0,
|
|
11
11
|
total_quantity: 0,
|
|
@@ -18,9 +18,16 @@ async function getCart(url, addressId) {
|
|
|
18
18
|
variant_discounts: {},
|
|
19
19
|
total_shipping: 0,
|
|
20
20
|
total_tax_amount: 0,
|
|
21
|
-
applied_coupon: {}
|
|
21
|
+
applied_coupon: {},
|
|
22
|
+
shipping_options: [],
|
|
23
|
+
selected_shipping_option_id: null,
|
|
24
|
+
selected_address_id: null
|
|
22
25
|
};
|
|
23
26
|
}
|
|
27
|
+
async function getCartItemQuantity() {
|
|
28
|
+
const localCart = cart_default.get();
|
|
29
|
+
return auth_default.getUserDetails() ? (await http_service_default.get("/customer/cart/quantity/")).data : { total_quantity: localCart?.total_quantity || 0 };
|
|
30
|
+
}
|
|
24
31
|
async function addToCart(product, customizationInputs) {
|
|
25
32
|
return http_service_default.post("/customer/cart/", {
|
|
26
33
|
action: "add",
|
|
@@ -112,4 +119,4 @@ async function removeFromWishlist(product_variants) {
|
|
|
112
119
|
});
|
|
113
120
|
}
|
|
114
121
|
|
|
115
|
-
export { addToCart, addWishlist, getCart, getCategories, getDigitalProductDownloadLink, getProductCategories, getProductDetail, getProductDetailBySlug, getProductList, getProducts, getWishlist, notifyProductStock, removeFromCart, removeFromWishlist, updateCart, updateDigitalProductDownloadLinkCount };
|
|
122
|
+
export { addToCart, addWishlist, getCart, getCartItemQuantity, getCategories, getDigitalProductDownloadLink, getProductCategories, getProductDetail, getProductDetailBySlug, getProductList, getProducts, getWishlist, notifyProductStock, removeFromCart, removeFromWishlist, updateCart, updateDigitalProductDownloadLinkCount };
|
|
@@ -12,6 +12,6 @@ import '../product-DJMdi4D4.cjs';
|
|
|
12
12
|
import 'react-toastify';
|
|
13
13
|
import 'react/jsx-runtime';
|
|
14
14
|
import '../orders-CjNmCY5I.cjs';
|
|
15
|
-
import '../pixelEvents-
|
|
16
|
-
import '../cart-
|
|
15
|
+
import '../pixelEvents-CXViXGtV.cjs';
|
|
16
|
+
import '../cart-CuLMWnfy.cjs';
|
|
17
17
|
import '../collections-WzvTO0OQ.cjs';
|
|
@@ -12,6 +12,6 @@ import '../product-DJMdi4D4.js';
|
|
|
12
12
|
import 'react-toastify';
|
|
13
13
|
import 'react/jsx-runtime';
|
|
14
14
|
import '../orders-L_8eIkUS.js';
|
|
15
|
-
import '../pixelEvents-
|
|
16
|
-
import '../cart-
|
|
15
|
+
import '../pixelEvents-LqK0Ltr_.js';
|
|
16
|
+
import '../cart-CLf2ljxd.js';
|
|
17
17
|
import '../collections-BDSVfRNo.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PageHeaderProps } from '../pixelEvents-
|
|
2
|
-
import '../cart-
|
|
1
|
+
import { P as PageHeaderProps } from '../pixelEvents-CXViXGtV.cjs';
|
|
2
|
+
import '../cart-CuLMWnfy.cjs';
|
|
3
3
|
import '../product-DJMdi4D4.cjs';
|
|
4
4
|
import 'react-toastify';
|
|
5
5
|
import '../collections-WzvTO0OQ.cjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PageHeaderProps } from '../pixelEvents-
|
|
2
|
-
import '../cart-
|
|
1
|
+
import { P as PageHeaderProps } from '../pixelEvents-LqK0Ltr_.js';
|
|
2
|
+
import '../cart-CLf2ljxd.js';
|
|
3
3
|
import '../product-DJMdi4D4.js';
|
|
4
4
|
import 'react-toastify';
|
|
5
5
|
import '../collections-BDSVfRNo.js';
|
package/dist/hooks/index.cjs
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkY46EHRJQ_cjs = require('../chunk-Y46EHRJQ.cjs');
|
|
4
4
|
var chunk2AHH3XBW_cjs = require('../chunk-2AHH3XBW.cjs');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
5
|
+
var chunk23YAZNVF_cjs = require('../chunk-23YAZNVF.cjs');
|
|
6
|
+
var chunkMTSMQAZR_cjs = require('../chunk-MTSMQAZR.cjs');
|
|
7
7
|
var chunkSMHJRNCR_cjs = require('../chunk-SMHJRNCR.cjs');
|
|
8
|
-
var
|
|
8
|
+
var chunkTLNCCSTQ_cjs = require('../chunk-TLNCCSTQ.cjs');
|
|
9
9
|
var chunkXFOUNOKO_cjs = require('../chunk-XFOUNOKO.cjs');
|
|
10
10
|
require('../chunk-K44JZ5NL.cjs');
|
|
11
|
-
var
|
|
11
|
+
var chunkDXQX7ZIL_cjs = require('../chunk-DXQX7ZIL.cjs');
|
|
12
12
|
var chunkKLNKIQQM_cjs = require('../chunk-KLNKIQQM.cjs');
|
|
13
13
|
var chunkRDUT4W3B_cjs = require('../chunk-RDUT4W3B.cjs');
|
|
14
14
|
require('../chunk-LJUGNSQQ.cjs');
|
|
@@ -55,7 +55,7 @@ var useCart = (addressId) => {
|
|
|
55
55
|
async (addrId) => {
|
|
56
56
|
try {
|
|
57
57
|
setIsLoading(true);
|
|
58
|
-
const result = await
|
|
58
|
+
const result = await chunkMTSMQAZR_cjs.getCart("/customer/cart/", addrId ?? addressId);
|
|
59
59
|
setData(result);
|
|
60
60
|
setError(null);
|
|
61
61
|
} catch (err) {
|
|
@@ -90,7 +90,7 @@ var useOrders = (filters) => {
|
|
|
90
90
|
try {
|
|
91
91
|
setIsLoading(true);
|
|
92
92
|
const url = `/customer/order/?${queryString}`;
|
|
93
|
-
const result = await
|
|
93
|
+
const result = await chunkDXQX7ZIL_cjs.getOrders(url);
|
|
94
94
|
setData(result);
|
|
95
95
|
setError(null);
|
|
96
96
|
} catch (err) {
|
|
@@ -127,7 +127,7 @@ function useGetProducts(initialFilter, options) {
|
|
|
127
127
|
apiParams[key] = value;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
const result = await
|
|
130
|
+
const result = await chunkMTSMQAZR_cjs.getProductList(endpoint, apiParams);
|
|
131
131
|
setData(result);
|
|
132
132
|
if (modeRef.current === "append" && isLoadMoreRef.current) {
|
|
133
133
|
setProducts((prev) => [...prev, ...result.results || []]);
|
|
@@ -195,7 +195,7 @@ var useGetProductDetails = (slug) => {
|
|
|
195
195
|
const fetchData = react.useCallback(async () => {
|
|
196
196
|
try {
|
|
197
197
|
setIsLoading(true);
|
|
198
|
-
const result = await
|
|
198
|
+
const result = await chunkMTSMQAZR_cjs.getProductDetail("/inventory/products/", slug);
|
|
199
199
|
setData(result);
|
|
200
200
|
} catch (err) {
|
|
201
201
|
} finally {
|
|
@@ -218,7 +218,7 @@ var useGetProductCategories = () => {
|
|
|
218
218
|
const fetchData = async () => {
|
|
219
219
|
try {
|
|
220
220
|
setIsLoading(true);
|
|
221
|
-
const result = await
|
|
221
|
+
const result = await chunkMTSMQAZR_cjs.getProductCategories("/store/categories");
|
|
222
222
|
setData(result || []);
|
|
223
223
|
} catch (err) {
|
|
224
224
|
setError(err);
|
|
@@ -263,7 +263,7 @@ var useWishlist = () => {
|
|
|
263
263
|
const fetchData = react.useCallback(async () => {
|
|
264
264
|
try {
|
|
265
265
|
setIsLoading(true);
|
|
266
|
-
const response = await
|
|
266
|
+
const response = await chunkMTSMQAZR_cjs.getWishlist("/customer/wishlist/");
|
|
267
267
|
if (response.data) setData(response.data);
|
|
268
268
|
setError(null);
|
|
269
269
|
} catch (err) {
|
|
@@ -321,7 +321,7 @@ function useCheckoutPayment(options) {
|
|
|
321
321
|
const [isConfirmingPayment, setIsConfirmingPayment] = react.useState(false);
|
|
322
322
|
const [showSuccessModal, setShowSuccessModal] = react.useState(false);
|
|
323
323
|
const [showFailureModal, setShowFailureModal] = react.useState(false);
|
|
324
|
-
const resetCartCount =
|
|
324
|
+
const resetCartCount = chunk23YAZNVF_cjs.useCartStore((s) => s.resetCartCount);
|
|
325
325
|
const callbacks = {
|
|
326
326
|
onSuccess: (order) => {
|
|
327
327
|
setOrderSummary(order);
|
|
@@ -340,20 +340,21 @@ function useCheckoutPayment(options) {
|
|
|
340
340
|
onPaymentEnd: () => setIsConfirmingPayment(false)
|
|
341
341
|
};
|
|
342
342
|
const placeAndPay = react.useCallback(
|
|
343
|
-
async (addressId, paymentMethod) => {
|
|
343
|
+
async (addressId, paymentMethod, shippingOptionId) => {
|
|
344
344
|
try {
|
|
345
345
|
setIsPlacingOrder(true);
|
|
346
346
|
const isCod = paymentMethod === "cod";
|
|
347
|
-
const response = await
|
|
347
|
+
const response = await chunkDXQX7ZIL_cjs.placeOrder(
|
|
348
348
|
addressId,
|
|
349
349
|
options.phonepeRedirectUrl,
|
|
350
350
|
isCod,
|
|
351
|
+
shippingOptionId,
|
|
351
352
|
options.stripeRedirectUrl,
|
|
352
353
|
options.tabbyRedirectUrl
|
|
353
354
|
);
|
|
354
355
|
const order = response.data;
|
|
355
356
|
setOrderSummary(order);
|
|
356
|
-
|
|
357
|
+
chunkTLNCCSTQ_cjs.processPayment(order, paymentMethod, callbacks);
|
|
357
358
|
} catch {
|
|
358
359
|
setShowFailureModal(true);
|
|
359
360
|
} finally {
|
|
@@ -383,7 +384,7 @@ function useCheckoutCoupon(options) {
|
|
|
383
384
|
const refreshCoupons = react.useCallback(async () => {
|
|
384
385
|
setIsLoading(true);
|
|
385
386
|
try {
|
|
386
|
-
const coupons = await
|
|
387
|
+
const coupons = await chunkTLNCCSTQ_cjs.fetchAvailableCoupons();
|
|
387
388
|
setAvailableCoupons(coupons);
|
|
388
389
|
} catch {
|
|
389
390
|
} finally {
|
|
@@ -395,7 +396,7 @@ function useCheckoutCoupon(options) {
|
|
|
395
396
|
setError(null);
|
|
396
397
|
setIsApplying(true);
|
|
397
398
|
try {
|
|
398
|
-
const coupon = await
|
|
399
|
+
const coupon = await chunkTLNCCSTQ_cjs.applyCheckoutCoupon(code, callbacks);
|
|
399
400
|
setAppliedCoupon(coupon);
|
|
400
401
|
} catch (err) {
|
|
401
402
|
setError(err instanceof Error ? err.message : "Failed to apply coupon");
|
|
@@ -408,7 +409,7 @@ function useCheckoutCoupon(options) {
|
|
|
408
409
|
const removeCouponHandler = react.useCallback(async () => {
|
|
409
410
|
if (!appliedCoupon) return;
|
|
410
411
|
try {
|
|
411
|
-
await
|
|
412
|
+
await chunkTLNCCSTQ_cjs.removeCheckoutCoupon(appliedCoupon.coupon_code, callbacks);
|
|
412
413
|
setAppliedCoupon(null);
|
|
413
414
|
setError(null);
|
|
414
415
|
} catch {
|
|
@@ -507,8 +508,8 @@ function useVariantSelector(options) {
|
|
|
507
508
|
}
|
|
508
509
|
function useShopCheckout(options) {
|
|
509
510
|
const { product, onNavigateToCart, onToast } = options;
|
|
510
|
-
const { addToCart, setCart } =
|
|
511
|
-
const isUserAuthenticated =
|
|
511
|
+
const { addToCart, setCart } = chunk23YAZNVF_cjs.useCartStore();
|
|
512
|
+
const isUserAuthenticated = chunk23YAZNVF_cjs.useAuthStore((s) => s.isAuthenticated);
|
|
512
513
|
const [isWishlisted, setIsWishlisted] = react.useState(product.is_wishlisted);
|
|
513
514
|
const [isAddedToCart, setIsAddedToCart] = react.useState(false);
|
|
514
515
|
const [loading, setLoading] = react.useState(false);
|
|
@@ -519,7 +520,7 @@ function useShopCheckout(options) {
|
|
|
519
520
|
react.useEffect(() => {
|
|
520
521
|
const fetchCategories = async () => {
|
|
521
522
|
try {
|
|
522
|
-
const response = await
|
|
523
|
+
const response = await chunkMTSMQAZR_cjs.getCategories();
|
|
523
524
|
setCategories(response.data);
|
|
524
525
|
} catch (error) {
|
|
525
526
|
console.log(error);
|
|
@@ -633,7 +634,7 @@ function useShopCheckout(options) {
|
|
|
633
634
|
const handleNotifyMeFormSubmit = react.useCallback(
|
|
634
635
|
async (values) => {
|
|
635
636
|
try {
|
|
636
|
-
const response = await
|
|
637
|
+
const response = await chunkMTSMQAZR_cjs.notifyProductStock({
|
|
637
638
|
...values,
|
|
638
639
|
variant_slug: product.slug
|
|
639
640
|
});
|
package/dist/hooks/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as Address } from '../address-DwBZHzbI.cjs';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { C as Cart, b as Category, U as User, c as Coupon } from '../cart-
|
|
3
|
+
import { C as Cart, b as Category, U as User, c as Coupon } from '../cart-CuLMWnfy.cjs';
|
|
4
4
|
import { O as Order } from '../orders-CjNmCY5I.cjs';
|
|
5
5
|
import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-DJMdi4D4.cjs';
|
|
6
6
|
import { W as Wishlist } from '../wishlist-CUuCTSVJ.cjs';
|
|
@@ -108,7 +108,7 @@ interface UseCheckoutPaymentReturn {
|
|
|
108
108
|
showFailureModal: boolean;
|
|
109
109
|
setShowSuccessModal: (show: boolean) => void;
|
|
110
110
|
setShowFailureModal: (show: boolean) => void;
|
|
111
|
-
placeAndPay: (addressId: number, paymentMethod: string) => Promise<void>;
|
|
111
|
+
placeAndPay: (addressId: number, paymentMethod: string, shippingOptionId?: number) => Promise<void>;
|
|
112
112
|
}
|
|
113
113
|
/**
|
|
114
114
|
* Hook that manages the full checkout payment flow:
|