@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
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
|
|
7
|
-
var
|
|
8
|
-
var
|
|
5
|
+
var chunkNOT6VKXA_cjs = require('../chunk-NOT6VKXA.cjs');
|
|
6
|
+
var chunkNRPK5GCJ_cjs = require('../chunk-NRPK5GCJ.cjs');
|
|
7
|
+
var chunkNQZ5GUOG_cjs = require('../chunk-NQZ5GUOG.cjs');
|
|
8
|
+
var chunk34Y7Y5FU_cjs = require('../chunk-34Y7Y5FU.cjs');
|
|
9
9
|
var chunkXFOUNOKO_cjs = require('../chunk-XFOUNOKO.cjs');
|
|
10
|
-
require('../chunk-
|
|
11
|
-
var
|
|
10
|
+
require('../chunk-NSAHGMS7.cjs');
|
|
11
|
+
var chunkH6FJYRO3_cjs = require('../chunk-H6FJYRO3.cjs');
|
|
12
12
|
var chunkIVKJJLG7_cjs = require('../chunk-IVKJJLG7.cjs');
|
|
13
13
|
var chunkRDUT4W3B_cjs = require('../chunk-RDUT4W3B.cjs');
|
|
14
14
|
require('../chunk-LJUGNSQQ.cjs');
|
|
@@ -56,7 +56,7 @@ var useCart = (addressId) => {
|
|
|
56
56
|
async (addrId, shippingId) => {
|
|
57
57
|
try {
|
|
58
58
|
setIsLoading(true);
|
|
59
|
-
const result = await
|
|
59
|
+
const result = await chunkNRPK5GCJ_cjs.getCart("/customer/cart/", addrId ?? addressId, shippingId);
|
|
60
60
|
setData(result);
|
|
61
61
|
setError(null);
|
|
62
62
|
} catch (err) {
|
|
@@ -91,7 +91,7 @@ var useOrders = (filters) => {
|
|
|
91
91
|
try {
|
|
92
92
|
setIsLoading(true);
|
|
93
93
|
const url = `/customer/order/?${queryString}`;
|
|
94
|
-
const result = await
|
|
94
|
+
const result = await chunkH6FJYRO3_cjs.getOrders(url);
|
|
95
95
|
setData(result);
|
|
96
96
|
setError(null);
|
|
97
97
|
} catch (err) {
|
|
@@ -128,7 +128,7 @@ function useGetProducts(initialFilter, options) {
|
|
|
128
128
|
apiParams[key] = value;
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
|
-
const result = await
|
|
131
|
+
const result = await chunkNRPK5GCJ_cjs.getProductList(endpoint, apiParams);
|
|
132
132
|
setData(result);
|
|
133
133
|
if (modeRef.current === "append" && isLoadMoreRef.current) {
|
|
134
134
|
setProducts((prev) => [...prev, ...result.results || []]);
|
|
@@ -196,7 +196,7 @@ var useGetProductDetails = (slug) => {
|
|
|
196
196
|
const fetchData = react.useCallback(async () => {
|
|
197
197
|
try {
|
|
198
198
|
setIsLoading(true);
|
|
199
|
-
const result = await
|
|
199
|
+
const result = await chunkNRPK5GCJ_cjs.getProductDetail("/inventory/products/", slug);
|
|
200
200
|
setData(result);
|
|
201
201
|
} catch (err) {
|
|
202
202
|
} finally {
|
|
@@ -219,7 +219,7 @@ var useGetProductCategories = () => {
|
|
|
219
219
|
const fetchData = async () => {
|
|
220
220
|
try {
|
|
221
221
|
setIsLoading(true);
|
|
222
|
-
const result = await
|
|
222
|
+
const result = await chunkNRPK5GCJ_cjs.getProductCategories("/store/categories");
|
|
223
223
|
setData(result || []);
|
|
224
224
|
} catch (err) {
|
|
225
225
|
setError(err);
|
|
@@ -264,7 +264,7 @@ var useWishlist = () => {
|
|
|
264
264
|
const fetchData = react.useCallback(async () => {
|
|
265
265
|
try {
|
|
266
266
|
setIsLoading(true);
|
|
267
|
-
const response = await
|
|
267
|
+
const response = await chunkNRPK5GCJ_cjs.getWishlist("/customer/wishlist/");
|
|
268
268
|
if (response.data) setData(response.data);
|
|
269
269
|
setError(null);
|
|
270
270
|
} catch (err) {
|
|
@@ -322,7 +322,7 @@ function useCheckoutPayment(options) {
|
|
|
322
322
|
const [isConfirmingPayment, setIsConfirmingPayment] = react.useState(false);
|
|
323
323
|
const [showSuccessModal, setShowSuccessModal] = react.useState(false);
|
|
324
324
|
const [showFailureModal, setShowFailureModal] = react.useState(false);
|
|
325
|
-
const resetCartCount =
|
|
325
|
+
const resetCartCount = chunkNOT6VKXA_cjs.useCartStore((s) => s.resetCartCount);
|
|
326
326
|
const callbacks = {
|
|
327
327
|
onSuccess: (order) => {
|
|
328
328
|
setOrderSummary(order);
|
|
@@ -345,7 +345,7 @@ function useCheckoutPayment(options) {
|
|
|
345
345
|
try {
|
|
346
346
|
setIsPlacingOrder(true);
|
|
347
347
|
const isCod = paymentMethod === "cod";
|
|
348
|
-
const response = await
|
|
348
|
+
const response = await chunkH6FJYRO3_cjs.placeOrder(
|
|
349
349
|
addressId,
|
|
350
350
|
options.phonepeRedirectUrl,
|
|
351
351
|
isCod,
|
|
@@ -355,8 +355,9 @@ function useCheckoutPayment(options) {
|
|
|
355
355
|
);
|
|
356
356
|
const order = response.data;
|
|
357
357
|
setOrderSummary(order);
|
|
358
|
-
|
|
359
|
-
} catch {
|
|
358
|
+
chunk34Y7Y5FU_cjs.processPayment(order, paymentMethod, callbacks);
|
|
359
|
+
} catch (error) {
|
|
360
|
+
if (options.onPlaceOrderError?.(error) === true) return;
|
|
360
361
|
setShowFailureModal(true);
|
|
361
362
|
} finally {
|
|
362
363
|
setIsPlacingOrder(false);
|
|
@@ -375,6 +376,538 @@ function useCheckoutPayment(options) {
|
|
|
375
376
|
placeAndPay
|
|
376
377
|
};
|
|
377
378
|
}
|
|
379
|
+
var BUY_NOW_PAYLOAD_KEY = "____bn_pl_";
|
|
380
|
+
var DEBOUNCE_MS = 300;
|
|
381
|
+
function messageForPreviewError(code, fallback, isPreorder) {
|
|
382
|
+
switch (code) {
|
|
383
|
+
case "FEATURE_NOT_AVAILABLE":
|
|
384
|
+
return isPreorder ? "Pre Order isn't available for this store." : "Buy Now isn't available for this store.";
|
|
385
|
+
case "PUBLIC_CHECKOUT_DISABLED":
|
|
386
|
+
return "Guest checkout isn't available for this store. Please log in to continue.";
|
|
387
|
+
case "VARIANT_NOT_FOUND":
|
|
388
|
+
return "This product is no longer available.";
|
|
389
|
+
case "VARIANT_UNAVAILABLE":
|
|
390
|
+
return "This product is currently unavailable.";
|
|
391
|
+
case "INVALID_QUANTITY":
|
|
392
|
+
return "Please choose a valid quantity.";
|
|
393
|
+
case "ADDRESS_NOT_FOUND":
|
|
394
|
+
return "The selected address could not be found. Please pick another.";
|
|
395
|
+
default:
|
|
396
|
+
return fallback || "We couldn't load this item. Please try again.";
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
function readStashedItem() {
|
|
400
|
+
if (typeof window === "undefined") return null;
|
|
401
|
+
try {
|
|
402
|
+
const raw = window.sessionStorage.getItem(BUY_NOW_PAYLOAD_KEY);
|
|
403
|
+
if (!raw) return null;
|
|
404
|
+
const parsed = JSON.parse(raw);
|
|
405
|
+
if (!parsed?.variant_id) return null;
|
|
406
|
+
return { ...parsed, quantity: parsed.quantity || 1 };
|
|
407
|
+
} catch {
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function useBuyNow(isAuthenticated = true) {
|
|
412
|
+
const [item, setItem] = react.useState(null);
|
|
413
|
+
const [quantity, setQuantityState] = react.useState(1);
|
|
414
|
+
const [couponCodes, setCouponCodes] = react.useState(void 0);
|
|
415
|
+
const [addressId, setAddressIdState] = react.useState(void 0);
|
|
416
|
+
const [guestAddress, setGuestAddressState] = react.useState(void 0);
|
|
417
|
+
const [shippingOptionId, setShippingOptionIdState] = react.useState(void 0);
|
|
418
|
+
const [preview, setPreview] = react.useState(null);
|
|
419
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
420
|
+
const [isRefreshing, setIsRefreshing] = react.useState(false);
|
|
421
|
+
const [placingOrder, setPlacingOrder] = react.useState(false);
|
|
422
|
+
const [notFound, setNotFound] = react.useState(false);
|
|
423
|
+
const [error, setError] = react.useState(null);
|
|
424
|
+
const [refreshNonce, setRefreshNonce] = react.useState(0);
|
|
425
|
+
const debounceRef = react.useRef();
|
|
426
|
+
const stateRef = react.useRef({ quantity, couponCodes, addressId, guestAddress, shippingOptionId, preview });
|
|
427
|
+
stateRef.current = { quantity, couponCodes, addressId, guestAddress, shippingOptionId, preview };
|
|
428
|
+
react.useEffect(() => {
|
|
429
|
+
const stashed = readStashedItem();
|
|
430
|
+
if (!stashed) {
|
|
431
|
+
setNotFound(true);
|
|
432
|
+
setIsLoading(false);
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
setItem(stashed);
|
|
436
|
+
setQuantityState(stashed.quantity || 1);
|
|
437
|
+
}, []);
|
|
438
|
+
const runPreview = react.useCallback(async (current) => {
|
|
439
|
+
const { quantity: quantity2, couponCodes: couponCodes2, addressId: addressId2, guestAddress: guestAddress2, shippingOptionId: shippingOptionId2 } = stateRef.current;
|
|
440
|
+
const payload = {
|
|
441
|
+
variant_id: current.variant_id,
|
|
442
|
+
quantity: quantity2,
|
|
443
|
+
customization_inputs: current.customization_inputs
|
|
444
|
+
};
|
|
445
|
+
if (couponCodes2 !== void 0) payload.coupon_codes = couponCodes2;
|
|
446
|
+
if (addressId2 !== void 0) payload.address_id = addressId2;
|
|
447
|
+
if (guestAddress2 !== void 0) payload.address = guestAddress2;
|
|
448
|
+
if (shippingOptionId2 !== void 0) payload.shipping_option_id = shippingOptionId2;
|
|
449
|
+
setIsRefreshing(true);
|
|
450
|
+
try {
|
|
451
|
+
const response = await chunkH6FJYRO3_cjs.buyNowPreview(payload);
|
|
452
|
+
if (response.data) {
|
|
453
|
+
setPreview(response.data);
|
|
454
|
+
setError(null);
|
|
455
|
+
}
|
|
456
|
+
} catch (err) {
|
|
457
|
+
const data = err?.response?.data;
|
|
458
|
+
setError({
|
|
459
|
+
code: data?.error_code || "INTERNAL_ERROR",
|
|
460
|
+
message: messageForPreviewError(data?.error_code, data?.error, current.is_preorder)
|
|
461
|
+
});
|
|
462
|
+
} finally {
|
|
463
|
+
setIsLoading(false);
|
|
464
|
+
setIsRefreshing(false);
|
|
465
|
+
}
|
|
466
|
+
}, []);
|
|
467
|
+
react.useEffect(() => {
|
|
468
|
+
if (!item) return;
|
|
469
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
470
|
+
debounceRef.current = setTimeout(() => runPreview(item), DEBOUNCE_MS);
|
|
471
|
+
return () => {
|
|
472
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
473
|
+
};
|
|
474
|
+
}, [item, quantity, couponCodes, addressId, guestAddress, shippingOptionId, refreshNonce, runPreview]);
|
|
475
|
+
const refresh = react.useCallback(() => {
|
|
476
|
+
setRefreshNonce((n) => n + 1);
|
|
477
|
+
}, []);
|
|
478
|
+
const clearItem = react.useCallback(() => {
|
|
479
|
+
try {
|
|
480
|
+
window.sessionStorage.removeItem(BUY_NOW_PAYLOAD_KEY);
|
|
481
|
+
} catch {
|
|
482
|
+
}
|
|
483
|
+
}, []);
|
|
484
|
+
const setQuantity = react.useCallback((value) => {
|
|
485
|
+
setQuantityState(Math.max(1, value));
|
|
486
|
+
}, []);
|
|
487
|
+
const setAddressId = react.useCallback((id) => {
|
|
488
|
+
setAddressIdState(id);
|
|
489
|
+
setShippingOptionIdState(void 0);
|
|
490
|
+
}, []);
|
|
491
|
+
const setGuestAddress = react.useCallback((address) => {
|
|
492
|
+
const prev = stateRef.current.guestAddress;
|
|
493
|
+
const unchanged = prev?.country_obj === address?.country_obj && prev?.state_obj === address?.state_obj && prev?.pincode === address?.pincode;
|
|
494
|
+
if (unchanged) return;
|
|
495
|
+
const destinationChanged = prev?.country_obj !== address?.country_obj || prev?.state_obj !== address?.state_obj;
|
|
496
|
+
setGuestAddressState(address);
|
|
497
|
+
if (destinationChanged) setShippingOptionIdState(void 0);
|
|
498
|
+
}, []);
|
|
499
|
+
const setShippingOptionId = react.useCallback((id) => {
|
|
500
|
+
setShippingOptionIdState(id);
|
|
501
|
+
}, []);
|
|
502
|
+
const applyCoupon2 = react.useCallback((code) => {
|
|
503
|
+
setCouponCodes([code]);
|
|
504
|
+
}, []);
|
|
505
|
+
const removeCoupon2 = react.useCallback(() => {
|
|
506
|
+
setCouponCodes([]);
|
|
507
|
+
}, []);
|
|
508
|
+
const placeOrder2 = react.useCallback(
|
|
509
|
+
async ({
|
|
510
|
+
isCod,
|
|
511
|
+
phonepeRedirectUrl,
|
|
512
|
+
stripeRedirectUrl,
|
|
513
|
+
tabbyRedirectUrl,
|
|
514
|
+
guest
|
|
515
|
+
}) => {
|
|
516
|
+
if (!item) return;
|
|
517
|
+
const effectiveShippingId = shippingOptionId ?? stateRef.current.preview?.selected_shipping_option_id ?? void 0;
|
|
518
|
+
setPlacingOrder(true);
|
|
519
|
+
try {
|
|
520
|
+
if (!isAuthenticated) {
|
|
521
|
+
if (!guest) throw new Error("MISSING_ADDRESS");
|
|
522
|
+
const payload2 = {
|
|
523
|
+
cart_items: { [item.variant_id]: quantity },
|
|
524
|
+
is_buy_now: true,
|
|
525
|
+
is_cod: !!isCod,
|
|
526
|
+
email: guest.email,
|
|
527
|
+
phone: guest.phone,
|
|
528
|
+
country_code: guest.country_code,
|
|
529
|
+
address: guest.address
|
|
530
|
+
};
|
|
531
|
+
if (couponCodes !== void 0) payload2.coupon_codes = couponCodes;
|
|
532
|
+
if (effectiveShippingId !== void 0 && effectiveShippingId !== null)
|
|
533
|
+
payload2.shipping_option_id = effectiveShippingId;
|
|
534
|
+
if (phonepeRedirectUrl) payload2.phonepe_redirect_url = phonepeRedirectUrl;
|
|
535
|
+
if (stripeRedirectUrl) payload2.stripe_redirect_url = stripeRedirectUrl;
|
|
536
|
+
if (tabbyRedirectUrl) payload2.tabby_redirect_url = tabbyRedirectUrl;
|
|
537
|
+
const response2 = await chunkH6FJYRO3_cjs.placeGuestBuyNowOrder(payload2);
|
|
538
|
+
return response2.data;
|
|
539
|
+
}
|
|
540
|
+
if (addressId === void 0) throw new Error("MISSING_ADDRESS");
|
|
541
|
+
const payload = {
|
|
542
|
+
variant_id: item.variant_id,
|
|
543
|
+
quantity,
|
|
544
|
+
address_id: addressId,
|
|
545
|
+
customization_inputs: item.customization_inputs,
|
|
546
|
+
is_cod: !!isCod
|
|
547
|
+
};
|
|
548
|
+
if (couponCodes !== void 0) payload.coupon_codes = couponCodes;
|
|
549
|
+
if (effectiveShippingId !== void 0 && effectiveShippingId !== null)
|
|
550
|
+
payload.shipping_option_id = effectiveShippingId;
|
|
551
|
+
if (phonepeRedirectUrl) payload.phonepe_redirect_url = phonepeRedirectUrl;
|
|
552
|
+
if (stripeRedirectUrl) payload.stripe_redirect_url = stripeRedirectUrl;
|
|
553
|
+
if (tabbyRedirectUrl) payload.tabby_redirect_url = tabbyRedirectUrl;
|
|
554
|
+
const response = await chunkH6FJYRO3_cjs.placeBuyNowOrder(payload);
|
|
555
|
+
return response.data;
|
|
556
|
+
} finally {
|
|
557
|
+
setPlacingOrder(false);
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
|
+
[item, quantity, addressId, couponCodes, shippingOptionId, isAuthenticated]
|
|
561
|
+
);
|
|
562
|
+
return {
|
|
563
|
+
// data
|
|
564
|
+
item,
|
|
565
|
+
preview,
|
|
566
|
+
quantity,
|
|
567
|
+
couponCodes,
|
|
568
|
+
addressId,
|
|
569
|
+
guestAddress,
|
|
570
|
+
shippingOptionId,
|
|
571
|
+
// status
|
|
572
|
+
isLoading,
|
|
573
|
+
isRefreshing,
|
|
574
|
+
placingOrder,
|
|
575
|
+
notFound,
|
|
576
|
+
error,
|
|
577
|
+
missingItems: preview?.missing_items ?? {},
|
|
578
|
+
appliedCoupon: preview?.applied_coupons && Object.keys(preview.applied_coupons).length > 0 ? preview.applied_coupons : null,
|
|
579
|
+
// actions
|
|
580
|
+
setQuantity,
|
|
581
|
+
setAddressId,
|
|
582
|
+
setShippingOptionId,
|
|
583
|
+
applyCoupon: applyCoupon2,
|
|
584
|
+
removeCoupon: removeCoupon2,
|
|
585
|
+
setGuestAddress,
|
|
586
|
+
refresh,
|
|
587
|
+
clearItem,
|
|
588
|
+
placeOrder: placeOrder2
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
function useInlineCheckoutPayment(options) {
|
|
592
|
+
const [orderSummary, setOrderSummary] = react.useState(null);
|
|
593
|
+
const [isPlacingOrder, setIsPlacingOrder] = react.useState(false);
|
|
594
|
+
const [isConfirmingPayment, setIsConfirmingPayment] = react.useState(false);
|
|
595
|
+
const [showSuccessModal, setShowSuccessModal] = react.useState(false);
|
|
596
|
+
const [showFailureModal, setShowFailureModal] = react.useState(false);
|
|
597
|
+
const isPublic = !options.isAuthenticated;
|
|
598
|
+
const callbacks = {
|
|
599
|
+
onSuccess: (order) => {
|
|
600
|
+
setOrderSummary(order);
|
|
601
|
+
setShowSuccessModal(true);
|
|
602
|
+
options.onClearItem?.();
|
|
603
|
+
options.onSuccess?.(order);
|
|
604
|
+
},
|
|
605
|
+
onFailure: (order) => {
|
|
606
|
+
setOrderSummary(order);
|
|
607
|
+
setShowFailureModal(true);
|
|
608
|
+
options.onFailure?.(order);
|
|
609
|
+
},
|
|
610
|
+
onRedirect: options.onRedirect,
|
|
611
|
+
onStripeModalOpen: options.onStripeModalOpen,
|
|
612
|
+
onCartReset: () => {
|
|
613
|
+
},
|
|
614
|
+
onPaymentStart: () => setIsConfirmingPayment(true),
|
|
615
|
+
onPaymentEnd: () => setIsConfirmingPayment(false)
|
|
616
|
+
};
|
|
617
|
+
const placeAndPay = react.useCallback(
|
|
618
|
+
async (paymentMethod) => {
|
|
619
|
+
try {
|
|
620
|
+
setIsPlacingOrder(true);
|
|
621
|
+
const isCod = paymentMethod === "cod";
|
|
622
|
+
const guest = isPublic ? options.getGuestContact?.() : void 0;
|
|
623
|
+
if (isPublic && !guest) {
|
|
624
|
+
setShowFailureModal(true);
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
const order = await options.placeOrder({
|
|
628
|
+
isCod,
|
|
629
|
+
phonepeRedirectUrl: options.phonepeRedirectUrl,
|
|
630
|
+
stripeRedirectUrl: options.stripeRedirectUrl,
|
|
631
|
+
tabbyRedirectUrl: options.tabbyRedirectUrl,
|
|
632
|
+
guest
|
|
633
|
+
});
|
|
634
|
+
if (!order) {
|
|
635
|
+
setShowFailureModal(true);
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
setOrderSummary(order);
|
|
639
|
+
chunk34Y7Y5FU_cjs.processPayment(order, paymentMethod, callbacks, { isPublic });
|
|
640
|
+
} catch (error) {
|
|
641
|
+
if (options.onPlaceOrderError?.(error) === true) return;
|
|
642
|
+
setShowFailureModal(true);
|
|
643
|
+
} finally {
|
|
644
|
+
setIsPlacingOrder(false);
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
[
|
|
648
|
+
isPublic,
|
|
649
|
+
options.placeOrder,
|
|
650
|
+
options.getGuestContact,
|
|
651
|
+
options.phonepeRedirectUrl,
|
|
652
|
+
options.stripeRedirectUrl,
|
|
653
|
+
options.tabbyRedirectUrl
|
|
654
|
+
]
|
|
655
|
+
);
|
|
656
|
+
return {
|
|
657
|
+
orderSummary,
|
|
658
|
+
isPlacingOrder,
|
|
659
|
+
isConfirmingPayment,
|
|
660
|
+
showSuccessModal,
|
|
661
|
+
showFailureModal,
|
|
662
|
+
setShowSuccessModal,
|
|
663
|
+
setShowFailureModal,
|
|
664
|
+
placeAndPay
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
var DEBOUNCE_MS2 = 400;
|
|
668
|
+
function messageForPreviewError2(code, fallback) {
|
|
669
|
+
switch (code) {
|
|
670
|
+
case "PUBLIC_CHECKOUT_DISABLED":
|
|
671
|
+
return "Guest checkout isn't available for this store. Please log in to continue.";
|
|
672
|
+
case "INVALID_QUANTITY":
|
|
673
|
+
return "One of the items has an invalid quantity. Please review your cart.";
|
|
674
|
+
case "ADDRESS_NOT_FOUND":
|
|
675
|
+
return "The selected address could not be found. Please pick another.";
|
|
676
|
+
case "PREORDER_DIRECT_ONLY":
|
|
677
|
+
return "A pre-order product is in your cart. Please remove it and purchase it directly with Pre Order.";
|
|
678
|
+
default:
|
|
679
|
+
return fallback || "We couldn't price your cart. Please try again.";
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
function readCartItems(cart) {
|
|
683
|
+
if (!cart?.products_quantity) return {};
|
|
684
|
+
return Object.entries(cart.products_quantity).reduce(
|
|
685
|
+
(acc, [id, qty]) => {
|
|
686
|
+
const variantId = Number(id);
|
|
687
|
+
const quantity = Number(qty);
|
|
688
|
+
if (variantId && quantity > 0) acc[variantId] = quantity;
|
|
689
|
+
return acc;
|
|
690
|
+
},
|
|
691
|
+
{}
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
function usePublicCheckout() {
|
|
695
|
+
const [cartItems, setCartItems] = react.useState({});
|
|
696
|
+
const [couponCodes, setCouponCodes] = react.useState(void 0);
|
|
697
|
+
const [guestAddress, setGuestAddressState] = react.useState(void 0);
|
|
698
|
+
const [shippingOptionId, setShippingOptionIdState] = react.useState(
|
|
699
|
+
void 0
|
|
700
|
+
);
|
|
701
|
+
const [isCod, setIsCodState] = react.useState(false);
|
|
702
|
+
const [preview, setPreview] = react.useState(null);
|
|
703
|
+
const [isLoading, setIsLoading] = react.useState(true);
|
|
704
|
+
const [isRefreshing, setIsRefreshing] = react.useState(false);
|
|
705
|
+
const [placingOrder, setPlacingOrder] = react.useState(false);
|
|
706
|
+
const [isEmpty, setIsEmpty] = react.useState(false);
|
|
707
|
+
const [error, setError] = react.useState(null);
|
|
708
|
+
const [refreshNonce, setRefreshNonce] = react.useState(0);
|
|
709
|
+
const debounceRef = react.useRef();
|
|
710
|
+
const stateRef = react.useRef({
|
|
711
|
+
cartItems,
|
|
712
|
+
couponCodes,
|
|
713
|
+
guestAddress,
|
|
714
|
+
shippingOptionId,
|
|
715
|
+
isCod,
|
|
716
|
+
preview
|
|
717
|
+
});
|
|
718
|
+
stateRef.current = {
|
|
719
|
+
cartItems,
|
|
720
|
+
couponCodes,
|
|
721
|
+
guestAddress,
|
|
722
|
+
shippingOptionId,
|
|
723
|
+
isCod,
|
|
724
|
+
preview
|
|
725
|
+
};
|
|
726
|
+
react.useEffect(() => {
|
|
727
|
+
const cart = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
728
|
+
const items = readCartItems(cart);
|
|
729
|
+
if (Object.keys(items).length === 0) {
|
|
730
|
+
setIsEmpty(true);
|
|
731
|
+
setIsLoading(false);
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
setCartItems(items);
|
|
735
|
+
}, []);
|
|
736
|
+
const pruneStaleItems = react.useCallback(
|
|
737
|
+
(priced) => {
|
|
738
|
+
const missing = priced.missing_items || {};
|
|
739
|
+
const missingIds = Object.keys(missing).map(Number);
|
|
740
|
+
if (missingIds.length === 0) return;
|
|
741
|
+
const pricedIds = new Set((priced.product_variants || []).map((v) => v.id));
|
|
742
|
+
const droppedIds = missingIds.filter((id) => !pricedIds.has(id));
|
|
743
|
+
if (droppedIds.length === 0) return;
|
|
744
|
+
const cart = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
745
|
+
if (cart) {
|
|
746
|
+
droppedIds.forEach((id) => {
|
|
747
|
+
const variant = cart.product_variants?.find((v) => v.id === id);
|
|
748
|
+
if (variant) chunkNQZ5GUOG_cjs.cart_default.remove(variant);
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
setCartItems((prev) => {
|
|
752
|
+
const next = { ...prev };
|
|
753
|
+
droppedIds.forEach((id) => delete next[id]);
|
|
754
|
+
return next;
|
|
755
|
+
});
|
|
756
|
+
},
|
|
757
|
+
[]
|
|
758
|
+
);
|
|
759
|
+
const runPreview = react.useCallback(async () => {
|
|
760
|
+
const {
|
|
761
|
+
cartItems: cartItems2,
|
|
762
|
+
couponCodes: couponCodes2,
|
|
763
|
+
guestAddress: guestAddress2,
|
|
764
|
+
shippingOptionId: shippingOptionId2,
|
|
765
|
+
isCod: isCod2
|
|
766
|
+
} = stateRef.current;
|
|
767
|
+
if (Object.keys(cartItems2).length === 0) {
|
|
768
|
+
setIsEmpty(true);
|
|
769
|
+
setIsLoading(false);
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
const payload = {
|
|
773
|
+
cart_items: cartItems2,
|
|
774
|
+
is_cod: isCod2
|
|
775
|
+
};
|
|
776
|
+
if (couponCodes2 !== void 0) payload.coupon_codes = couponCodes2;
|
|
777
|
+
if (guestAddress2 !== void 0) payload.address = guestAddress2;
|
|
778
|
+
if (shippingOptionId2 !== void 0) payload.shipping_option_id = shippingOptionId2;
|
|
779
|
+
setIsRefreshing(true);
|
|
780
|
+
try {
|
|
781
|
+
const response = await chunkH6FJYRO3_cjs.publicCheckoutPreview(payload);
|
|
782
|
+
if (response.data) {
|
|
783
|
+
setPreview(response.data);
|
|
784
|
+
setError(null);
|
|
785
|
+
pruneStaleItems(response.data);
|
|
786
|
+
}
|
|
787
|
+
} catch (err) {
|
|
788
|
+
const data = err?.response?.data;
|
|
789
|
+
const code = data?.error_code;
|
|
790
|
+
if (code === "CART_EMPTY") {
|
|
791
|
+
chunkNQZ5GUOG_cjs.cart_default.clear();
|
|
792
|
+
setCartItems({});
|
|
793
|
+
setIsEmpty(true);
|
|
794
|
+
setPreview(null);
|
|
795
|
+
setError(null);
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
setError({
|
|
799
|
+
code: code || "INTERNAL_ERROR",
|
|
800
|
+
message: messageForPreviewError2(code, data?.error)
|
|
801
|
+
});
|
|
802
|
+
} finally {
|
|
803
|
+
setIsLoading(false);
|
|
804
|
+
setIsRefreshing(false);
|
|
805
|
+
}
|
|
806
|
+
}, [pruneStaleItems]);
|
|
807
|
+
react.useEffect(() => {
|
|
808
|
+
if (isEmpty) return;
|
|
809
|
+
if (Object.keys(cartItems).length === 0) return;
|
|
810
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
811
|
+
debounceRef.current = setTimeout(runPreview, DEBOUNCE_MS2);
|
|
812
|
+
return () => {
|
|
813
|
+
if (debounceRef.current) clearTimeout(debounceRef.current);
|
|
814
|
+
};
|
|
815
|
+
}, [
|
|
816
|
+
cartItems,
|
|
817
|
+
couponCodes,
|
|
818
|
+
guestAddress,
|
|
819
|
+
shippingOptionId,
|
|
820
|
+
isCod,
|
|
821
|
+
refreshNonce,
|
|
822
|
+
isEmpty,
|
|
823
|
+
runPreview
|
|
824
|
+
]);
|
|
825
|
+
const refresh = react.useCallback(() => setRefreshNonce((n) => n + 1), []);
|
|
826
|
+
const setGuestAddress = react.useCallback((address) => {
|
|
827
|
+
const prev = stateRef.current.guestAddress;
|
|
828
|
+
const unchanged = prev?.country_obj === address?.country_obj && prev?.state_obj === address?.state_obj && prev?.pincode === address?.pincode;
|
|
829
|
+
if (unchanged) return;
|
|
830
|
+
const destinationChanged = prev?.country_obj !== address?.country_obj || prev?.state_obj !== address?.state_obj;
|
|
831
|
+
setGuestAddressState(address);
|
|
832
|
+
if (destinationChanged) setShippingOptionIdState(void 0);
|
|
833
|
+
}, []);
|
|
834
|
+
const setShippingOptionId = react.useCallback((id) => {
|
|
835
|
+
setShippingOptionIdState(id);
|
|
836
|
+
}, []);
|
|
837
|
+
const setIsCod = react.useCallback((value) => setIsCodState(value), []);
|
|
838
|
+
const applyCoupon2 = react.useCallback((code) => setCouponCodes([code]), []);
|
|
839
|
+
const removeCoupon2 = react.useCallback(() => setCouponCodes([]), []);
|
|
840
|
+
const clearCart = react.useCallback(() => {
|
|
841
|
+
chunkNQZ5GUOG_cjs.cart_default.clear();
|
|
842
|
+
setCartItems({});
|
|
843
|
+
setIsEmpty(true);
|
|
844
|
+
}, []);
|
|
845
|
+
const placeOrder2 = react.useCallback(
|
|
846
|
+
async ({
|
|
847
|
+
isCod: isCodArg,
|
|
848
|
+
phonepeRedirectUrl,
|
|
849
|
+
stripeRedirectUrl,
|
|
850
|
+
tabbyRedirectUrl,
|
|
851
|
+
guest
|
|
852
|
+
}) => {
|
|
853
|
+
if (!guest) throw new Error("MISSING_ADDRESS");
|
|
854
|
+
const items = stateRef.current.cartItems;
|
|
855
|
+
if (Object.keys(items).length === 0) throw new Error("CART_EMPTY");
|
|
856
|
+
setPlacingOrder(true);
|
|
857
|
+
try {
|
|
858
|
+
const payload = {
|
|
859
|
+
cart_items: items,
|
|
860
|
+
is_cod: !!isCodArg,
|
|
861
|
+
email: guest.email,
|
|
862
|
+
phone: guest.phone,
|
|
863
|
+
country_code: guest.country_code,
|
|
864
|
+
address: guest.address
|
|
865
|
+
};
|
|
866
|
+
if (couponCodes !== void 0) payload.coupon_codes = couponCodes;
|
|
867
|
+
const effectiveShippingId = shippingOptionId ?? stateRef.current.preview?.selected_shipping_option_id ?? void 0;
|
|
868
|
+
if (effectiveShippingId !== void 0 && effectiveShippingId !== null) {
|
|
869
|
+
payload.shipping_option_id = effectiveShippingId;
|
|
870
|
+
}
|
|
871
|
+
if (phonepeRedirectUrl) payload.phonepe_redirect_url = phonepeRedirectUrl;
|
|
872
|
+
if (stripeRedirectUrl) payload.stripe_redirect_url = stripeRedirectUrl;
|
|
873
|
+
if (tabbyRedirectUrl) payload.tabby_redirect_url = tabbyRedirectUrl;
|
|
874
|
+
const response = await chunkH6FJYRO3_cjs.placePublicOrder(payload);
|
|
875
|
+
return response.data;
|
|
876
|
+
} finally {
|
|
877
|
+
setPlacingOrder(false);
|
|
878
|
+
}
|
|
879
|
+
},
|
|
880
|
+
[couponCodes, shippingOptionId]
|
|
881
|
+
);
|
|
882
|
+
return {
|
|
883
|
+
// data
|
|
884
|
+
preview,
|
|
885
|
+
cartItems,
|
|
886
|
+
couponCodes,
|
|
887
|
+
guestAddress,
|
|
888
|
+
shippingOptionId,
|
|
889
|
+
isCod,
|
|
890
|
+
isCodEnabled: !!preview?.is_cod_enabled,
|
|
891
|
+
codAmount: Number(preview?.cod_amount || 0),
|
|
892
|
+
// status
|
|
893
|
+
isLoading,
|
|
894
|
+
isRefreshing,
|
|
895
|
+
placingOrder,
|
|
896
|
+
isEmpty,
|
|
897
|
+
error,
|
|
898
|
+
missingItems: preview?.missing_items ?? {},
|
|
899
|
+
appliedCoupon: preview?.applied_coupons && Object.keys(preview.applied_coupons).length > 0 ? preview.applied_coupons : null,
|
|
900
|
+
// actions
|
|
901
|
+
setGuestAddress,
|
|
902
|
+
setShippingOptionId,
|
|
903
|
+
setIsCod,
|
|
904
|
+
applyCoupon: applyCoupon2,
|
|
905
|
+
removeCoupon: removeCoupon2,
|
|
906
|
+
refresh,
|
|
907
|
+
clearCart,
|
|
908
|
+
placeOrder: placeOrder2
|
|
909
|
+
};
|
|
910
|
+
}
|
|
378
911
|
function useCheckoutCoupon(options) {
|
|
379
912
|
const [availableCoupons, setAvailableCoupons] = react.useState([]);
|
|
380
913
|
const [appliedCoupon, setAppliedCoupon] = react.useState(null);
|
|
@@ -385,7 +918,7 @@ function useCheckoutCoupon(options) {
|
|
|
385
918
|
const refreshCoupons = react.useCallback(async () => {
|
|
386
919
|
setIsLoading(true);
|
|
387
920
|
try {
|
|
388
|
-
const coupons = await
|
|
921
|
+
const coupons = await chunk34Y7Y5FU_cjs.fetchAvailableCoupons();
|
|
389
922
|
setAvailableCoupons(coupons);
|
|
390
923
|
} catch {
|
|
391
924
|
} finally {
|
|
@@ -397,7 +930,7 @@ function useCheckoutCoupon(options) {
|
|
|
397
930
|
setError(null);
|
|
398
931
|
setIsApplying(true);
|
|
399
932
|
try {
|
|
400
|
-
const coupon = await
|
|
933
|
+
const coupon = await chunk34Y7Y5FU_cjs.applyCheckoutCoupon(code, callbacks);
|
|
401
934
|
setAppliedCoupon(coupon);
|
|
402
935
|
} catch (err) {
|
|
403
936
|
setError(err instanceof Error ? err.message : "Failed to apply coupon");
|
|
@@ -410,7 +943,7 @@ function useCheckoutCoupon(options) {
|
|
|
410
943
|
const removeCouponHandler = react.useCallback(async () => {
|
|
411
944
|
if (!appliedCoupon) return;
|
|
412
945
|
try {
|
|
413
|
-
await
|
|
946
|
+
await chunk34Y7Y5FU_cjs.removeCheckoutCoupon(appliedCoupon.coupon_code, callbacks);
|
|
414
947
|
setAppliedCoupon(null);
|
|
415
948
|
setError(null);
|
|
416
949
|
} catch {
|
|
@@ -508,9 +1041,10 @@ function useVariantSelector(options) {
|
|
|
508
1041
|
};
|
|
509
1042
|
}
|
|
510
1043
|
function useShopCheckout(options) {
|
|
511
|
-
const { product, onNavigateToCart, onToast } = options;
|
|
512
|
-
const { addToCart, setCart } =
|
|
513
|
-
const
|
|
1044
|
+
const { product, onNavigateToCart, onToast, onPreorderRejected } = options;
|
|
1045
|
+
const { addToCart, setCart } = chunkNOT6VKXA_cjs.useCartStore();
|
|
1046
|
+
const cart = chunkNOT6VKXA_cjs.useCartStore((s) => s.cart);
|
|
1047
|
+
const isUserAuthenticated = chunkNOT6VKXA_cjs.useAuthStore((s) => s.isAuthenticated);
|
|
514
1048
|
const [isWishlisted, setIsWishlisted] = react.useState(product.is_wishlisted);
|
|
515
1049
|
const [isAddedToCart, setIsAddedToCart] = react.useState(false);
|
|
516
1050
|
const [loading, setLoading] = react.useState(false);
|
|
@@ -518,10 +1052,27 @@ function useShopCheckout(options) {
|
|
|
518
1052
|
const [showLoginModal, setShowLoginModal] = react.useState(false);
|
|
519
1053
|
const [showNotifyMeModal, setShowNotifyMeModal] = react.useState(false);
|
|
520
1054
|
const [categories, setCategories] = react.useState([]);
|
|
1055
|
+
const [cartQuantity, setCartQuantity] = react.useState(
|
|
1056
|
+
Number(product.cart_quantity) || 0
|
|
1057
|
+
);
|
|
1058
|
+
react.useEffect(() => {
|
|
1059
|
+
let inCart;
|
|
1060
|
+
if (!isUserAuthenticated) {
|
|
1061
|
+
inCart = Number(chunkNQZ5GUOG_cjs.cart_default.get()?.products_quantity?.[product.id]) || 0;
|
|
1062
|
+
} else if (cart) {
|
|
1063
|
+
inCart = cart.total_quantity > 0 ? Number(cart.products_quantity?.[product.id]) || 0 : 0;
|
|
1064
|
+
} else if (product.cart_quantity !== void 0) {
|
|
1065
|
+
inCart = Number(product.cart_quantity) || 0;
|
|
1066
|
+
}
|
|
1067
|
+
if (inCart !== void 0) {
|
|
1068
|
+
setCartQuantity(inCart);
|
|
1069
|
+
setIsAddedToCart(inCart > 0);
|
|
1070
|
+
}
|
|
1071
|
+
}, [product.id, product.cart_quantity, cart, isUserAuthenticated]);
|
|
521
1072
|
react.useEffect(() => {
|
|
522
1073
|
const fetchCategories = async () => {
|
|
523
1074
|
try {
|
|
524
|
-
const response = await
|
|
1075
|
+
const response = await chunkNRPK5GCJ_cjs.getCategories();
|
|
525
1076
|
setCategories(response.data);
|
|
526
1077
|
} catch (error) {
|
|
527
1078
|
console.log(error);
|
|
@@ -543,13 +1094,18 @@ function useShopCheckout(options) {
|
|
|
543
1094
|
await addToCart([{ variant_id: product.id, quantity }]);
|
|
544
1095
|
setIsAddedToCart(true);
|
|
545
1096
|
} catch (error) {
|
|
546
|
-
|
|
1097
|
+
const code = error?.response?.data?.error_code;
|
|
1098
|
+
if (code === "PREORDER_DIRECT_ONLY" && onPreorderRejected) {
|
|
1099
|
+
onPreorderRejected();
|
|
1100
|
+
} else {
|
|
1101
|
+
console.log(error);
|
|
1102
|
+
}
|
|
547
1103
|
} finally {
|
|
548
1104
|
setLoading(false);
|
|
549
1105
|
}
|
|
550
1106
|
} else {
|
|
551
|
-
|
|
552
|
-
const localCartItems =
|
|
1107
|
+
chunkNQZ5GUOG_cjs.cart_default.add(product, quantity);
|
|
1108
|
+
const localCartItems = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
553
1109
|
if (localCartItems) {
|
|
554
1110
|
setCart(localCartItems);
|
|
555
1111
|
}
|
|
@@ -562,7 +1118,8 @@ function useShopCheckout(options) {
|
|
|
562
1118
|
quantity,
|
|
563
1119
|
addToCart,
|
|
564
1120
|
setCart,
|
|
565
|
-
onNavigateToCart
|
|
1121
|
+
onNavigateToCart,
|
|
1122
|
+
onPreorderRejected
|
|
566
1123
|
]);
|
|
567
1124
|
const handleCustomizationSubmit = react.useCallback(
|
|
568
1125
|
async (data) => {
|
|
@@ -594,8 +1151,8 @@ function useShopCheckout(options) {
|
|
|
594
1151
|
setLoading(false);
|
|
595
1152
|
}
|
|
596
1153
|
} else {
|
|
597
|
-
|
|
598
|
-
const localCartItems =
|
|
1154
|
+
chunkNQZ5GUOG_cjs.cart_default.add(product, quantity);
|
|
1155
|
+
const localCartItems = chunkNQZ5GUOG_cjs.cart_default.get();
|
|
599
1156
|
if (localCartItems) {
|
|
600
1157
|
setCart(localCartItems);
|
|
601
1158
|
}
|
|
@@ -635,7 +1192,7 @@ function useShopCheckout(options) {
|
|
|
635
1192
|
const handleNotifyMeFormSubmit = react.useCallback(
|
|
636
1193
|
async (values) => {
|
|
637
1194
|
try {
|
|
638
|
-
const response = await
|
|
1195
|
+
const response = await chunkNRPK5GCJ_cjs.notifyProductStock({
|
|
639
1196
|
...values,
|
|
640
1197
|
variant_slug: product.slug
|
|
641
1198
|
});
|
|
@@ -665,6 +1222,7 @@ function useShopCheckout(options) {
|
|
|
665
1222
|
return {
|
|
666
1223
|
isWishlisted,
|
|
667
1224
|
isAddedToCart,
|
|
1225
|
+
cartQuantity,
|
|
668
1226
|
loading,
|
|
669
1227
|
quantity,
|
|
670
1228
|
showLoginModal,
|
|
@@ -772,7 +1330,9 @@ Object.defineProperty(exports, "useAddressForm", {
|
|
|
772
1330
|
enumerable: true,
|
|
773
1331
|
get: function () { return chunkIVKJJLG7_cjs.useAddressForm; }
|
|
774
1332
|
});
|
|
1333
|
+
exports.BUY_NOW_PAYLOAD_KEY = BUY_NOW_PAYLOAD_KEY;
|
|
775
1334
|
exports.useAddress = useAddress;
|
|
1335
|
+
exports.useBuyNow = useBuyNow;
|
|
776
1336
|
exports.useCart = useCart;
|
|
777
1337
|
exports.useCheckoutCoupon = useCheckoutCoupon;
|
|
778
1338
|
exports.useCheckoutPayment = useCheckoutPayment;
|
|
@@ -780,8 +1340,10 @@ exports.useCoupon = useCoupon;
|
|
|
780
1340
|
exports.useGetProductCategories = useGetProductCategories;
|
|
781
1341
|
exports.useGetProductDetails = useGetProductDetails;
|
|
782
1342
|
exports.useGetProducts = useGetProducts;
|
|
1343
|
+
exports.useInlineCheckoutPayment = useInlineCheckoutPayment;
|
|
783
1344
|
exports.useOrders = useOrders;
|
|
784
1345
|
exports.useProductDetailModal = useProductDetailModal;
|
|
1346
|
+
exports.usePublicCheckout = usePublicCheckout;
|
|
785
1347
|
exports.useServiceFormModal = useServiceFormModal;
|
|
786
1348
|
exports.useShopCheckout = useShopCheckout;
|
|
787
1349
|
exports.useUserDetails = useUserDetails;
|