@storepecker/storefront-core 2.7.0 → 2.9.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.
- package/dist/api/index.cjs +94 -46
- package/dist/api/index.d.cts +108 -11
- package/dist/api/index.d.ts +108 -11
- package/dist/api/index.js +3 -3
- package/dist/buy-now-BqVWXyy8.d.cts +197 -0
- package/dist/buy-now-DFdnuLjO.d.ts +197 -0
- package/dist/{cart-BGIsIZdM.d.ts → cart-DZq1ZEnE.d.ts} +1 -1
- package/dist/{cart-CyN2JQTw.d.cts → cart-DwMFBmpC.d.cts} +1 -1
- package/dist/checkout/index.cjs +85 -38
- package/dist/checkout/index.d.cts +49 -11
- package/dist/checkout/index.d.ts +49 -11
- package/dist/checkout/index.js +65 -19
- package/dist/{chunk-KWYFA2LJ.cjs → chunk-34Y7Y5FU.cjs} +49 -31
- package/dist/{chunk-GTV42PDK.cjs → chunk-57UU7IJ2.cjs} +1 -0
- package/dist/{chunk-RNGQUWQW.cjs → chunk-H6FJYRO3.cjs} +49 -1
- package/dist/{chunk-CHRTGR3G.js → chunk-KCLVR6G5.js} +39 -2
- package/dist/{chunk-IWYO22XV.cjs → chunk-NOT6VKXA.cjs} +37 -39
- package/dist/{chunk-LCMJYFHC.cjs → chunk-NQZ5GUOG.cjs} +0 -1
- package/dist/{chunk-5BT3MH4A.cjs → chunk-NRPK5GCJ.cjs} +11 -3
- package/dist/{chunk-K44JZ5NL.cjs → chunk-NSAHGMS7.cjs} +6 -1
- package/dist/{chunk-4C4NTH6O.js → chunk-OOFYY6GR.js} +1 -0
- package/dist/{chunk-6QHEH5XE.js → chunk-QQHQTBAM.js} +20 -22
- package/dist/{chunk-H32TICAM.js → chunk-TH7OAMGC.js} +0 -1
- package/dist/{chunk-WFDKKOO7.js → chunk-VAU5OL72.js} +6 -1
- package/dist/{chunk-5JD6MRVS.js → chunk-VPTN4YXD.js} +36 -18
- package/dist/{chunk-TY5NK7NW.js → chunk-ZAWZ3RB6.js} +9 -2
- package/dist/{collections-ycrA2cPL.d.ts → collections-CNh2OGbl.d.ts} +1 -1
- package/dist/{collections-8YdINtUf.d.cts → collections-CXgOv5_G.d.cts} +1 -1
- package/dist/components/digital-product-download-modal.d.cts +2 -2
- package/dist/components/digital-product-download-modal.d.ts +2 -2
- package/dist/components/index.d.cts +5 -5
- package/dist/components/index.d.ts +5 -5
- package/dist/components/share-button.d.cts +1 -1
- package/dist/components/share-button.d.ts +1 -1
- package/dist/components/theme-data-initializer.d.cts +5 -5
- package/dist/components/theme-data-initializer.d.ts +5 -5
- package/dist/hooks/index.cjs +592 -30
- package/dist/hooks/index.d.cts +183 -5
- package/dist/hooks/index.d.ts +183 -5
- package/dist/hooks/index.js +569 -11
- package/dist/{instagram-CqJBZ-0X.d.ts → instagram-BADLnNQ3.d.ts} +1 -1
- package/dist/{instagram-D4JUT4ZU.d.cts → instagram-DalreBu6.d.cts} +1 -1
- package/dist/middleware/index.cjs +3 -3
- package/dist/middleware/index.js +1 -1
- package/dist/models/index.d.cts +7 -6
- package/dist/models/index.d.ts +7 -6
- package/dist/{orders-C1XZr8tx.d.ts → orders-B3G4CyhH.d.cts} +2 -1
- package/dist/{orders-9_scVq_M.d.cts → orders-Bl-Slh72.d.ts} +2 -1
- package/dist/{pixelEvents-uiPHbiAQ.d.cts → pixelEvents-BtEO5QAR.d.cts} +5 -4
- package/dist/{pixelEvents-D0sH22Er.d.ts → pixelEvents-LsealscG.d.ts} +5 -4
- package/dist/{product-CZtFWhxO.d.ts → product-D9liEtl4.d.cts} +1 -0
- package/dist/{product-CZtFWhxO.d.cts → product-D9liEtl4.d.ts} +1 -0
- package/dist/store/index.cjs +9 -9
- package/dist/store/index.d.cts +12 -7
- package/dist/store/index.d.ts +12 -7
- package/dist/store/index.js +4 -4
- package/dist/utils/index.cjs +9 -9
- package/dist/utils/index.d.cts +8 -7
- package/dist/utils/index.d.ts +8 -7
- package/dist/utils/index.js +3 -3
- package/dist/{wishlist-Cx9Vrszq.d.cts → wishlist-BakHvIFN.d.cts} +1 -1
- package/dist/{wishlist-CRNbfFIx.d.ts → wishlist-Cj0sQxiY.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -54,12 +54,44 @@ async function publicPlaceOrder(address, redirect, orderDetails, stripeRedirect,
|
|
|
54
54
|
...orderDetails
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
+
async function buyNowPreview(payload) {
|
|
58
|
+
return http_service_default.post("/customer/buy_now/preview/", payload);
|
|
59
|
+
}
|
|
60
|
+
async function placeBuyNowOrder(payload) {
|
|
61
|
+
return http_service_default.post("/customer/buy_now/", payload);
|
|
62
|
+
}
|
|
63
|
+
async function placeGuestBuyNowOrder(payload) {
|
|
64
|
+
return http_service_default.post("/customer/public_order/", payload);
|
|
65
|
+
}
|
|
66
|
+
async function publicCheckoutPreview(payload) {
|
|
67
|
+
return http_service_default.post("/customer/public_order/preview/", payload);
|
|
68
|
+
}
|
|
69
|
+
async function placePublicOrder(payload) {
|
|
70
|
+
return http_service_default.post("/customer/public_order/", payload);
|
|
71
|
+
}
|
|
57
72
|
async function updateOrder(orderDetails) {
|
|
58
73
|
return http_service_default.patch("/customer/order/", orderDetails);
|
|
59
74
|
}
|
|
60
75
|
async function razorpayPublicOrderSuccess(orderDetails) {
|
|
61
76
|
return http_service_default.post("/payment/public-razorpay-order-success/", orderDetails);
|
|
62
77
|
}
|
|
78
|
+
async function publicRazorpayOrderFailure(orderDetails) {
|
|
79
|
+
return http_service_default.post("/payment/public-razorpay-order-failure/", orderDetails);
|
|
80
|
+
}
|
|
81
|
+
async function publicPhonepeOrderFailure(payload) {
|
|
82
|
+
return http_service_default.post("/payment/public-phonepe-order-failure/", payload);
|
|
83
|
+
}
|
|
84
|
+
async function phonepePaymentFailure(payload) {
|
|
85
|
+
return http_service_default.post("/payment/phonepe-order-failure/", payload);
|
|
86
|
+
}
|
|
87
|
+
async function publicStripeOrderFailure(orderDetails) {
|
|
88
|
+
return http_service_default.post("/payment/public-stripe-order-failure/", orderDetails);
|
|
89
|
+
}
|
|
90
|
+
async function tabbyPaymentFailure(paymentId) {
|
|
91
|
+
return http_service_default.post("/payment/tabby-payment-failure/", {
|
|
92
|
+
payment_id: paymentId
|
|
93
|
+
});
|
|
94
|
+
}
|
|
63
95
|
async function razorpayOrderSuccess(orderDetails) {
|
|
64
96
|
return http_service_default.post("/payment/razorpay-order-success/", orderDetails);
|
|
65
97
|
}
|
|
@@ -77,6 +109,11 @@ async function checkPhonepePaymentStatus(transactionId) {
|
|
|
77
109
|
params: { phonepe_transaction_id: transactionId }
|
|
78
110
|
});
|
|
79
111
|
}
|
|
112
|
+
async function checkPhonepePaymentStatusPublic(transactionId) {
|
|
113
|
+
return http_service_default.get("/payment/public-phonepe-order-success/", {
|
|
114
|
+
params: { phonepe_transaction_id: transactionId }
|
|
115
|
+
});
|
|
116
|
+
}
|
|
80
117
|
async function getStripePaymentStatus(stripeCheckoutSessionId, order_number, payment_link_id) {
|
|
81
118
|
return http_service_default.get("/payment/stripe-payment-status/", {
|
|
82
119
|
params: {
|
|
@@ -102,7 +139,7 @@ async function stripeOrderSuccess(orderDetails) {
|
|
|
102
139
|
return http_service_default.post("/payment/stripe-order-success/", orderDetails);
|
|
103
140
|
}
|
|
104
141
|
async function stripeOrderFail(orderDetails) {
|
|
105
|
-
return http_service_default.post("/payment/stripe-order-
|
|
142
|
+
return http_service_default.post("/payment/stripe-order-failure/", orderDetails);
|
|
106
143
|
}
|
|
107
144
|
async function makeCODOrder(orderId) {
|
|
108
145
|
return http_service_default.post("/customer/order_cod/", { order_id: orderId });
|
|
@@ -126,4 +163,4 @@ async function verifyTabbyPayment(orderNumber) {
|
|
|
126
163
|
});
|
|
127
164
|
}
|
|
128
165
|
|
|
129
|
-
export { checkPhonepePaymentStatus, getOrderDetails, getOrderDetailsByNumber, getOrderDetailsByRef, getOrderDetailsByRefV2, getOrders, getPublicOrderDetailsByNumber, getPublicOrderDetailsByRef, getStripePaymentStatus, getStripePaymentStatusPublic, makeCODOrder, phonepeOrderSuccess, phonepePublicOrderSuccess, placeOrder, publicMakeCODOrder, publicPlaceOrder, razorpayOrderFail, razorpayOrderSuccess, razorpayPublicOrderSuccess, stripeOrderFail, stripeOrderSuccess, stripePublicOrderSuccess, updateOrder, updateOrderCustomization, uploadCustomizationImage, verifyTabbyPayment };
|
|
166
|
+
export { buyNowPreview, checkPhonepePaymentStatus, checkPhonepePaymentStatusPublic, getOrderDetails, getOrderDetailsByNumber, getOrderDetailsByRef, getOrderDetailsByRefV2, getOrders, getPublicOrderDetailsByNumber, getPublicOrderDetailsByRef, getStripePaymentStatus, getStripePaymentStatusPublic, makeCODOrder, phonepeOrderSuccess, phonepePaymentFailure, phonepePublicOrderSuccess, placeBuyNowOrder, placeGuestBuyNowOrder, placeOrder, placePublicOrder, publicCheckoutPreview, publicMakeCODOrder, publicPhonepeOrderFailure, publicPlaceOrder, publicRazorpayOrderFailure, publicStripeOrderFailure, razorpayOrderFail, razorpayOrderSuccess, razorpayPublicOrderSuccess, stripeOrderFail, stripeOrderSuccess, stripePublicOrderSuccess, tabbyPaymentFailure, updateOrder, updateOrderCustomization, uploadCustomizationImage, verifyTabbyPayment };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkNRPK5GCJ_cjs = require('./chunk-NRPK5GCJ.cjs');
|
|
4
|
+
var chunkNQZ5GUOG_cjs = require('./chunk-NQZ5GUOG.cjs');
|
|
5
|
+
var chunkH6FJYRO3_cjs = require('./chunk-H6FJYRO3.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');
|
|
@@ -23,7 +23,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
23
23
|
}),
|
|
24
24
|
fetchCartItemQuantity: async () => {
|
|
25
25
|
try {
|
|
26
|
-
const { total_quantity } = await
|
|
26
|
+
const { total_quantity } = await chunkNRPK5GCJ_cjs.getCartItemQuantity();
|
|
27
27
|
set({ total_quantity });
|
|
28
28
|
} catch (error) {
|
|
29
29
|
console.error("Failed to fetch cart item quantity", error);
|
|
@@ -32,7 +32,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
32
32
|
syncCart: async (addressId, shippingOptionId) => {
|
|
33
33
|
set({ status: "loading" /* LOADING */ });
|
|
34
34
|
try {
|
|
35
|
-
const response = await
|
|
35
|
+
const response = await chunkNRPK5GCJ_cjs.getCart("/customer/cart/", addressId, shippingOptionId);
|
|
36
36
|
if (response) {
|
|
37
37
|
set({ cart: response, total_quantity: response.total_quantity, status: "idle" /* IDLE */ });
|
|
38
38
|
}
|
|
@@ -43,7 +43,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
43
43
|
fetchCart: async (addressId, shippingOptionId) => {
|
|
44
44
|
set({ status: "loading" /* LOADING */ });
|
|
45
45
|
try {
|
|
46
|
-
const response = await
|
|
46
|
+
const response = await chunkNRPK5GCJ_cjs.getCart("/customer/cart/", addressId, shippingOptionId);
|
|
47
47
|
if (response) {
|
|
48
48
|
set({ cart: response, total_quantity: response.total_quantity, status: "idle" /* IDLE */ });
|
|
49
49
|
}
|
|
@@ -51,25 +51,20 @@ var useCartStore = zustand.create((set) => ({
|
|
|
51
51
|
set({ status: "idle" /* IDLE */ });
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
|
-
addToCart: async (items, customizationInputs, addressId) => {
|
|
54
|
+
addToCart: async (items, customizationInputs, addressId, products) => {
|
|
55
55
|
set({ status: "loading" /* LOADING */ });
|
|
56
56
|
try {
|
|
57
57
|
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
58
|
-
await
|
|
58
|
+
await chunkNRPK5GCJ_cjs.addToCart(items, customizationInputs);
|
|
59
59
|
await useCartStore.getState().syncCart(addressId);
|
|
60
60
|
} else {
|
|
61
|
-
const cart =
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
chunkLCMJYFHC_cjs.cart_default.add(product, item.quantity);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
const updatedCart = chunkLCMJYFHC_cjs.cart_default.get();
|
|
61
|
+
const cart = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
62
|
+
items.forEach((item) => {
|
|
63
|
+
const product = products?.find((p) => p.id === item.variant_id) || cart?.product_variants?.find((p) => p.id === item.variant_id);
|
|
64
|
+
if (!product) return;
|
|
65
|
+
chunkNQZ5GUOG_cjs.cart_default.add(product, item.quantity);
|
|
66
|
+
});
|
|
67
|
+
const updatedCart = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
73
68
|
if (updatedCart) {
|
|
74
69
|
set({ cart: updatedCart, total_quantity: updatedCart.total_quantity });
|
|
75
70
|
}
|
|
@@ -83,19 +78,19 @@ var useCartStore = zustand.create((set) => ({
|
|
|
83
78
|
set({ status: "loading" /* LOADING */ });
|
|
84
79
|
try {
|
|
85
80
|
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
86
|
-
await
|
|
81
|
+
await chunkNRPK5GCJ_cjs.removeFromCart(items);
|
|
87
82
|
await useCartStore.getState().syncCart(addressId);
|
|
88
83
|
} else {
|
|
89
|
-
const cart =
|
|
84
|
+
const cart = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
90
85
|
if (cart) {
|
|
91
86
|
items.forEach((item) => {
|
|
92
87
|
const product = cart.product_variants.find(
|
|
93
88
|
(p) => p.id === item.variant_id
|
|
94
89
|
);
|
|
95
|
-
if (product)
|
|
90
|
+
if (product) chunkNQZ5GUOG_cjs.cart_default.remove(product);
|
|
96
91
|
});
|
|
97
92
|
}
|
|
98
|
-
const updatedCart =
|
|
93
|
+
const updatedCart = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
99
94
|
if (updatedCart) {
|
|
100
95
|
set({
|
|
101
96
|
cart: updatedCart,
|
|
@@ -114,19 +109,19 @@ var useCartStore = zustand.create((set) => ({
|
|
|
114
109
|
set({ status: "loading" /* LOADING */ });
|
|
115
110
|
try {
|
|
116
111
|
if (chunkBBRXE57K_cjs.auth_default.getUserDetails()) {
|
|
117
|
-
await
|
|
112
|
+
await chunkNRPK5GCJ_cjs.updateCart(items);
|
|
118
113
|
await useCartStore.getState().syncCart(addressId);
|
|
119
114
|
} else {
|
|
120
|
-
const cart =
|
|
115
|
+
const cart = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
121
116
|
if (cart) {
|
|
122
117
|
items.forEach((item) => {
|
|
123
118
|
const product = cart.product_variants.find(
|
|
124
119
|
(p) => p.id === item.variant_id
|
|
125
120
|
);
|
|
126
|
-
if (product)
|
|
121
|
+
if (product) chunkNQZ5GUOG_cjs.cart_default.updateQuantity(product, item.quantity);
|
|
127
122
|
});
|
|
128
123
|
}
|
|
129
|
-
const updatedCart =
|
|
124
|
+
const updatedCart = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
130
125
|
if (updatedCart) {
|
|
131
126
|
set({
|
|
132
127
|
cart: updatedCart,
|
|
@@ -142,7 +137,7 @@ var useCartStore = zustand.create((set) => ({
|
|
|
142
137
|
updateCustomization: async (customizationInputs) => {
|
|
143
138
|
set({ status: "loading" /* LOADING */ });
|
|
144
139
|
try {
|
|
145
|
-
await
|
|
140
|
+
await chunkH6FJYRO3_cjs.updateOrderCustomization({ customization_inputs: customizationInputs });
|
|
146
141
|
} catch {
|
|
147
142
|
} finally {
|
|
148
143
|
set({ status: "idle" /* IDLE */ });
|
|
@@ -174,17 +169,10 @@ var useAuthStore = zustand.create((set, get) => ({
|
|
|
174
169
|
setTimeout(async () => {
|
|
175
170
|
try {
|
|
176
171
|
set({ user, status: "success" /* SUCCESS */, isAuthenticated: true });
|
|
177
|
-
const localCartItems =
|
|
172
|
+
const localCartItems = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
178
173
|
if (localCartItems) {
|
|
179
|
-
await
|
|
180
|
-
|
|
181
|
-
([key, value]) => ({
|
|
182
|
-
variant_id: parseInt(key),
|
|
183
|
-
quantity: value
|
|
184
|
-
})
|
|
185
|
-
)
|
|
186
|
-
);
|
|
187
|
-
chunkLCMJYFHC_cjs.cart_default.clear();
|
|
174
|
+
await mergeLocalCart(localCartItems);
|
|
175
|
+
chunkNQZ5GUOG_cjs.cart_default.clear();
|
|
188
176
|
await useCartStore.getState().fetchCart();
|
|
189
177
|
setTimeout(() => {
|
|
190
178
|
if (!preventRefreshAfterLogin) {
|
|
@@ -215,6 +203,16 @@ var useAuthStore = zustand.create((set, get) => ({
|
|
|
215
203
|
}, 1e3);
|
|
216
204
|
}
|
|
217
205
|
}));
|
|
206
|
+
async function mergeLocalCart(localCart) {
|
|
207
|
+
const cartItems = Object.entries(localCart.products_quantity || {}).map(([key, value]) => ({
|
|
208
|
+
variant_id: parseInt(key),
|
|
209
|
+
quantity: value
|
|
210
|
+
})).filter(
|
|
211
|
+
(item) => !Number.isNaN(item.variant_id) && Number.isInteger(item.quantity) && item.quantity >= 1
|
|
212
|
+
);
|
|
213
|
+
if (cartItems.length === 0) return;
|
|
214
|
+
await chunkNRPK5GCJ_cjs.mergeCart(cartItems, localCart.customization_inputs);
|
|
215
|
+
}
|
|
218
216
|
var loginUser = async (user) => {
|
|
219
217
|
const { access, refresh, ...userData } = user;
|
|
220
218
|
localStorage.setItem(chunkNE3ZHELZ_cjs.USER_CREDENTIALS, JSON.stringify(userData));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNQZ5GUOG_cjs = require('./chunk-NQZ5GUOG.cjs');
|
|
4
4
|
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
8
|
async function getCart(url, addressId, shippingOptionId) {
|
|
9
|
-
const localCart =
|
|
9
|
+
const localCart = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
10
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,
|
|
@@ -28,7 +28,7 @@ async function getCart(url, addressId, shippingOptionId) {
|
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
async function getCartItemQuantity() {
|
|
31
|
-
const localCart =
|
|
31
|
+
const localCart = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
32
32
|
return chunkBBRXE57K_cjs.auth_default.getUserDetails() ? (await chunkECHV2JSY_cjs.http_service_default.get("/customer/cart/quantity/")).data : { total_quantity: localCart?.total_quantity || 0 };
|
|
33
33
|
}
|
|
34
34
|
async function addToCart(product, customizationInputs) {
|
|
@@ -38,6 +38,13 @@ async function addToCart(product, customizationInputs) {
|
|
|
38
38
|
customization_inputs: customizationInputs
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
+
async function mergeCart(product, customizationInputs) {
|
|
42
|
+
return chunkECHV2JSY_cjs.http_service_default.post("/customer/cart/", {
|
|
43
|
+
action: "merge",
|
|
44
|
+
cart_items: product,
|
|
45
|
+
customization_inputs: customizationInputs
|
|
46
|
+
});
|
|
47
|
+
}
|
|
41
48
|
async function removeFromCart(product) {
|
|
42
49
|
return chunkECHV2JSY_cjs.http_service_default.post("/customer/cart/", {
|
|
43
50
|
action: "remove",
|
|
@@ -134,6 +141,7 @@ exports.getProductDetailBySlug = getProductDetailBySlug;
|
|
|
134
141
|
exports.getProductList = getProductList;
|
|
135
142
|
exports.getProducts = getProducts;
|
|
136
143
|
exports.getWishlist = getWishlist;
|
|
144
|
+
exports.mergeCart = mergeCart;
|
|
137
145
|
exports.notifyProductStock = notifyProductStock;
|
|
138
146
|
exports.removeFromCart = removeFromCart;
|
|
139
147
|
exports.removeFromWishlist = removeFromWishlist;
|
|
@@ -31,6 +31,7 @@ var pixelEvents = {
|
|
|
31
31
|
content_slug: product.slug,
|
|
32
32
|
content_name: product.name,
|
|
33
33
|
content_type: "product",
|
|
34
|
+
currency: window.currency_code || "INR",
|
|
34
35
|
price: Number(product.selling_price) * quantity,
|
|
35
36
|
num_items: quantity,
|
|
36
37
|
attributes: product.attributes
|
|
@@ -46,6 +47,7 @@ var pixelEvents = {
|
|
|
46
47
|
content_slug: product.slug,
|
|
47
48
|
content_name: product.name,
|
|
48
49
|
content_type: "product",
|
|
50
|
+
currency: window.currency_code || "INR",
|
|
49
51
|
price: Number(product.selling_price),
|
|
50
52
|
attributes: product.attributes
|
|
51
53
|
});
|
|
@@ -63,6 +65,7 @@ var pixelEvents = {
|
|
|
63
65
|
content_slug: product.slug,
|
|
64
66
|
content_name: product.name,
|
|
65
67
|
content_type: "product",
|
|
68
|
+
currency: window.currency_code || "INR",
|
|
66
69
|
price: Number(product.selling_price),
|
|
67
70
|
attributes: product.attributes
|
|
68
71
|
});
|
|
@@ -144,6 +147,7 @@ var pixelEvents = {
|
|
|
144
147
|
try {
|
|
145
148
|
window.fbq("track", "cart_viewed", {
|
|
146
149
|
content_type: "cart",
|
|
150
|
+
currency: window.currency_code || "INR",
|
|
147
151
|
value: cart.total_amount,
|
|
148
152
|
number_of_products: cart.total_quantity
|
|
149
153
|
});
|
|
@@ -161,7 +165,7 @@ var pixelEvents = {
|
|
|
161
165
|
content_ids: [orderSummary.order_number],
|
|
162
166
|
order_number: orderSummary.order_number,
|
|
163
167
|
content_type: "product",
|
|
164
|
-
currency: "INR",
|
|
168
|
+
currency: window.currency_code || "INR",
|
|
165
169
|
value: orderSummary.total_amount,
|
|
166
170
|
num_items: orderSummary.purchased_products.length,
|
|
167
171
|
contents: orderSummary.purchased_products.map((item) => ({
|
|
@@ -192,6 +196,7 @@ var pixelEvents = {
|
|
|
192
196
|
if (!window.fbq) return;
|
|
193
197
|
try {
|
|
194
198
|
window.fbq("track", "checkout_started", {
|
|
199
|
+
currency: window.currency_code || "INR",
|
|
195
200
|
value: cart.total_amount,
|
|
196
201
|
number_of_products: cart.total_quantity
|
|
197
202
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { updateCart, removeFromCart, addToCart, getCart, getCartItemQuantity } from './chunk-
|
|
2
|
-
import { cart_default } from './chunk-
|
|
3
|
-
import { updateOrderCustomization } from './chunk-
|
|
1
|
+
import { updateCart, removeFromCart, addToCart, getCart, getCartItemQuantity, mergeCart } from './chunk-ZAWZ3RB6.js';
|
|
2
|
+
import { cart_default } from './chunk-TH7OAMGC.js';
|
|
3
|
+
import { updateOrderCustomization } from './chunk-KCLVR6G5.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';
|
|
@@ -49,7 +49,7 @@ var useCartStore = create((set) => ({
|
|
|
49
49
|
set({ status: "idle" /* IDLE */ });
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
|
-
addToCart: async (items, customizationInputs, addressId) => {
|
|
52
|
+
addToCart: async (items, customizationInputs, addressId, products) => {
|
|
53
53
|
set({ status: "loading" /* LOADING */ });
|
|
54
54
|
try {
|
|
55
55
|
if (auth_default.getUserDetails()) {
|
|
@@ -57,16 +57,11 @@ var useCartStore = create((set) => ({
|
|
|
57
57
|
await useCartStore.getState().syncCart(addressId);
|
|
58
58
|
} else {
|
|
59
59
|
const cart = cart_default.get();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (product) {
|
|
66
|
-
cart_default.add(product, item.quantity);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
60
|
+
items.forEach((item) => {
|
|
61
|
+
const product = products?.find((p) => p.id === item.variant_id) || cart?.product_variants?.find((p) => p.id === item.variant_id);
|
|
62
|
+
if (!product) return;
|
|
63
|
+
cart_default.add(product, item.quantity);
|
|
64
|
+
});
|
|
70
65
|
const updatedCart = cart_default.get();
|
|
71
66
|
if (updatedCart) {
|
|
72
67
|
set({ cart: updatedCart, total_quantity: updatedCart.total_quantity });
|
|
@@ -174,14 +169,7 @@ var useAuthStore = create((set, get) => ({
|
|
|
174
169
|
set({ user, status: "success" /* SUCCESS */, isAuthenticated: true });
|
|
175
170
|
const localCartItems = cart_default.get();
|
|
176
171
|
if (localCartItems) {
|
|
177
|
-
await
|
|
178
|
-
Object.entries(localCartItems.products_quantity).map(
|
|
179
|
-
([key, value]) => ({
|
|
180
|
-
variant_id: parseInt(key),
|
|
181
|
-
quantity: value
|
|
182
|
-
})
|
|
183
|
-
)
|
|
184
|
-
);
|
|
172
|
+
await mergeLocalCart(localCartItems);
|
|
185
173
|
cart_default.clear();
|
|
186
174
|
await useCartStore.getState().fetchCart();
|
|
187
175
|
setTimeout(() => {
|
|
@@ -213,6 +201,16 @@ var useAuthStore = create((set, get) => ({
|
|
|
213
201
|
}, 1e3);
|
|
214
202
|
}
|
|
215
203
|
}));
|
|
204
|
+
async function mergeLocalCart(localCart) {
|
|
205
|
+
const cartItems = Object.entries(localCart.products_quantity || {}).map(([key, value]) => ({
|
|
206
|
+
variant_id: parseInt(key),
|
|
207
|
+
quantity: value
|
|
208
|
+
})).filter(
|
|
209
|
+
(item) => !Number.isNaN(item.variant_id) && Number.isInteger(item.quantity) && item.quantity >= 1
|
|
210
|
+
);
|
|
211
|
+
if (cartItems.length === 0) return;
|
|
212
|
+
await mergeCart(cartItems, localCart.customization_inputs);
|
|
213
|
+
}
|
|
216
214
|
var loginUser = async (user) => {
|
|
217
215
|
const { access, refresh, ...userData } = user;
|
|
218
216
|
localStorage.setItem(USER_CREDENTIALS, JSON.stringify(userData));
|
|
@@ -29,6 +29,7 @@ var pixelEvents = {
|
|
|
29
29
|
content_slug: product.slug,
|
|
30
30
|
content_name: product.name,
|
|
31
31
|
content_type: "product",
|
|
32
|
+
currency: window.currency_code || "INR",
|
|
32
33
|
price: Number(product.selling_price) * quantity,
|
|
33
34
|
num_items: quantity,
|
|
34
35
|
attributes: product.attributes
|
|
@@ -44,6 +45,7 @@ var pixelEvents = {
|
|
|
44
45
|
content_slug: product.slug,
|
|
45
46
|
content_name: product.name,
|
|
46
47
|
content_type: "product",
|
|
48
|
+
currency: window.currency_code || "INR",
|
|
47
49
|
price: Number(product.selling_price),
|
|
48
50
|
attributes: product.attributes
|
|
49
51
|
});
|
|
@@ -61,6 +63,7 @@ var pixelEvents = {
|
|
|
61
63
|
content_slug: product.slug,
|
|
62
64
|
content_name: product.name,
|
|
63
65
|
content_type: "product",
|
|
66
|
+
currency: window.currency_code || "INR",
|
|
64
67
|
price: Number(product.selling_price),
|
|
65
68
|
attributes: product.attributes
|
|
66
69
|
});
|
|
@@ -142,6 +145,7 @@ var pixelEvents = {
|
|
|
142
145
|
try {
|
|
143
146
|
window.fbq("track", "cart_viewed", {
|
|
144
147
|
content_type: "cart",
|
|
148
|
+
currency: window.currency_code || "INR",
|
|
145
149
|
value: cart.total_amount,
|
|
146
150
|
number_of_products: cart.total_quantity
|
|
147
151
|
});
|
|
@@ -159,7 +163,7 @@ var pixelEvents = {
|
|
|
159
163
|
content_ids: [orderSummary.order_number],
|
|
160
164
|
order_number: orderSummary.order_number,
|
|
161
165
|
content_type: "product",
|
|
162
|
-
currency: "INR",
|
|
166
|
+
currency: window.currency_code || "INR",
|
|
163
167
|
value: orderSummary.total_amount,
|
|
164
168
|
num_items: orderSummary.purchased_products.length,
|
|
165
169
|
contents: orderSummary.purchased_products.map((item) => ({
|
|
@@ -190,6 +194,7 @@ var pixelEvents = {
|
|
|
190
194
|
if (!window.fbq) return;
|
|
191
195
|
try {
|
|
192
196
|
window.fbq("track", "checkout_started", {
|
|
197
|
+
currency: window.currency_code || "INR",
|
|
193
198
|
value: cart.total_amount,
|
|
194
199
|
number_of_products: cart.total_quantity
|
|
195
200
|
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getCoupons, getAppliedCoupon, applyCoupon, removeCoupon } from './chunk-7M5CVYZJ.js';
|
|
2
|
-
import { pixelEvents } from './chunk-
|
|
3
|
-
import { razorpayOrderSuccess, razorpayOrderFail, publicMakeCODOrder, makeCODOrder, stripeOrderSuccess } from './chunk-
|
|
2
|
+
import { pixelEvents } from './chunk-VAU5OL72.js';
|
|
3
|
+
import { razorpayPublicOrderSuccess, razorpayOrderSuccess, publicRazorpayOrderFailure, razorpayOrderFail, publicMakeCODOrder, makeCODOrder, stripePublicOrderSuccess, stripeOrderSuccess } from './chunk-KCLVR6G5.js';
|
|
4
4
|
import { getCloudFront } from './chunk-JQMLHRWL.js';
|
|
5
5
|
import { AxiosError } from 'axios';
|
|
6
6
|
|
|
7
7
|
// src/checkout/payment.ts
|
|
8
|
-
function openRazorpayCheckout(order, callbacks) {
|
|
8
|
+
function openRazorpayCheckout(order, callbacks, paymentOptions) {
|
|
9
9
|
if (!order) return;
|
|
10
10
|
pixelEvents.initiateCheckout(order, "razorpay");
|
|
11
11
|
const {
|
|
@@ -39,7 +39,8 @@ function openRazorpayCheckout(order, callbacks) {
|
|
|
39
39
|
payment_id: response.razorpay_payment_id
|
|
40
40
|
},
|
|
41
41
|
order,
|
|
42
|
-
callbacks
|
|
42
|
+
callbacks,
|
|
43
|
+
paymentOptions
|
|
43
44
|
);
|
|
44
45
|
},
|
|
45
46
|
theme: {
|
|
@@ -52,22 +53,33 @@ function openRazorpayCheckout(order, callbacks) {
|
|
|
52
53
|
phone: customer_phone
|
|
53
54
|
},
|
|
54
55
|
modal: {
|
|
55
|
-
ondismiss: () => handleRazorpayFail(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
ondismiss: () => handleRazorpayFail(
|
|
57
|
+
order,
|
|
58
|
+
callbacks,
|
|
59
|
+
{
|
|
60
|
+
description: "User cancelled the payment manually",
|
|
61
|
+
reason: "user_cancelled_payment_manually"
|
|
62
|
+
},
|
|
63
|
+
{ isPublic: paymentOptions?.isPublic }
|
|
64
|
+
)
|
|
59
65
|
}
|
|
60
66
|
};
|
|
61
67
|
const paymentObject = new window.Razorpay(options);
|
|
62
68
|
paymentObject.on("payment.failed", (response) => {
|
|
63
|
-
handleRazorpayFail(order, callbacks, response?.error
|
|
69
|
+
handleRazorpayFail(order, callbacks, response?.error, {
|
|
70
|
+
isPublic: paymentOptions?.isPublic
|
|
71
|
+
});
|
|
64
72
|
});
|
|
65
73
|
paymentObject.open();
|
|
66
74
|
}
|
|
67
|
-
async function handleRazorpaySuccess(data, order, callbacks) {
|
|
75
|
+
async function handleRazorpaySuccess(data, order, callbacks, options) {
|
|
68
76
|
try {
|
|
69
77
|
callbacks.onPaymentStart?.();
|
|
70
|
-
|
|
78
|
+
if (options?.isPublic) {
|
|
79
|
+
await razorpayPublicOrderSuccess(data);
|
|
80
|
+
} else {
|
|
81
|
+
await razorpayOrderSuccess(data);
|
|
82
|
+
}
|
|
71
83
|
pixelEvents.purchase(order);
|
|
72
84
|
pixelEvents.checkoutCompleted(order);
|
|
73
85
|
callbacks.onCartReset();
|
|
@@ -78,13 +90,14 @@ async function handleRazorpaySuccess(data, order, callbacks) {
|
|
|
78
90
|
callbacks.onPaymentEnd?.();
|
|
79
91
|
}
|
|
80
92
|
}
|
|
81
|
-
async function handleRazorpayFail(order, callbacks, error) {
|
|
93
|
+
async function handleRazorpayFail(order, callbacks, error, options) {
|
|
82
94
|
try {
|
|
83
|
-
|
|
95
|
+
const payload = {
|
|
84
96
|
order_id: order.id,
|
|
85
97
|
razorpay_order_id: order.razorpay_order_id,
|
|
86
98
|
error
|
|
87
|
-
}
|
|
99
|
+
};
|
|
100
|
+
options?.isPublic ? await publicRazorpayOrderFailure(payload) : await razorpayOrderFail(payload);
|
|
88
101
|
} catch {
|
|
89
102
|
}
|
|
90
103
|
callbacks.onFailure(order);
|
|
@@ -143,13 +156,18 @@ function handleStripePayment(order, callbacks) {
|
|
|
143
156
|
}
|
|
144
157
|
callbacks.onFailure(order);
|
|
145
158
|
}
|
|
146
|
-
async function handleStripeSuccess(order, paymentIntentId, callbacks) {
|
|
159
|
+
async function handleStripeSuccess(order, paymentIntentId, callbacks, options) {
|
|
147
160
|
try {
|
|
148
161
|
callbacks.onPaymentStart?.();
|
|
149
|
-
|
|
162
|
+
const stripeSuccessPayload = {
|
|
150
163
|
order_id: order.id,
|
|
151
164
|
payment_intent_id: paymentIntentId
|
|
152
|
-
}
|
|
165
|
+
};
|
|
166
|
+
if (options?.isPublic) {
|
|
167
|
+
await stripePublicOrderSuccess(stripeSuccessPayload);
|
|
168
|
+
} else {
|
|
169
|
+
await stripeOrderSuccess(stripeSuccessPayload);
|
|
170
|
+
}
|
|
153
171
|
pixelEvents.purchase(order);
|
|
154
172
|
pixelEvents.checkoutCompleted(order);
|
|
155
173
|
callbacks.onCartReset();
|
|
@@ -174,7 +192,7 @@ function processPayment(order, paymentMethod, callbacks, options) {
|
|
|
174
192
|
return;
|
|
175
193
|
}
|
|
176
194
|
if (order.razorpay_public_token) {
|
|
177
|
-
openRazorpayCheckout(order, callbacks);
|
|
195
|
+
openRazorpayCheckout(order, callbacks, options);
|
|
178
196
|
return;
|
|
179
197
|
}
|
|
180
198
|
handlePhonepePayment(order, callbacks);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cart_default } from './chunk-
|
|
1
|
+
import { cart_default } from './chunk-TH7OAMGC.js';
|
|
2
2
|
import { http_service_default } from './chunk-3SYYP3XV.js';
|
|
3
3
|
import { auth_default } from './chunk-WEMNXIRS.js';
|
|
4
4
|
|
|
@@ -36,6 +36,13 @@ async function addToCart(product, customizationInputs) {
|
|
|
36
36
|
customization_inputs: customizationInputs
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
async function mergeCart(product, customizationInputs) {
|
|
40
|
+
return http_service_default.post("/customer/cart/", {
|
|
41
|
+
action: "merge",
|
|
42
|
+
cart_items: product,
|
|
43
|
+
customization_inputs: customizationInputs
|
|
44
|
+
});
|
|
45
|
+
}
|
|
39
46
|
async function removeFromCart(product) {
|
|
40
47
|
return http_service_default.post("/customer/cart/", {
|
|
41
48
|
action: "remove",
|
|
@@ -120,4 +127,4 @@ async function removeFromWishlist(product_variants) {
|
|
|
120
127
|
});
|
|
121
128
|
}
|
|
122
129
|
|
|
123
|
-
export { addToCart, addWishlist, getCart, getCartItemQuantity, getCategories, getDigitalProductDownloadLink, getProductCategories, getProductDetail, getProductDetailBySlug, getProductList, getProducts, getWishlist, notifyProductStock, removeFromCart, removeFromWishlist, updateCart, updateDigitalProductDownloadLinkCount };
|
|
130
|
+
export { addToCart, addWishlist, getCart, getCartItemQuantity, getCategories, getDigitalProductDownloadLink, getProductCategories, getProductDetail, getProductDetailBySlug, getProductList, getProducts, getWishlist, mergeCart, notifyProductStock, removeFromCart, removeFromWishlist, updateCart, updateDigitalProductDownloadLinkCount };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as Order } from '../orders-
|
|
2
|
-
import { f as ProductDetail } from '../product-
|
|
1
|
+
import { O as Order } from '../orders-B3G4CyhH.cjs';
|
|
2
|
+
import { f as ProductDetail } from '../product-D9liEtl4.cjs';
|
|
3
3
|
import 'react-toastify';
|
|
4
4
|
|
|
5
5
|
interface DigitalProductDownloadModalProps {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as Order } from '../orders-
|
|
2
|
-
import { f as ProductDetail } from '../product-
|
|
1
|
+
import { O as Order } from '../orders-Bl-Slh72.js';
|
|
2
|
+
import { f as ProductDetail } from '../product-D9liEtl4.js';
|
|
3
3
|
import 'react-toastify';
|
|
4
4
|
|
|
5
5
|
interface DigitalProductDownloadModalProps {
|