@storepecker/storefront-core 2.9.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.
Files changed (55) hide show
  1. package/dist/api/index.cjs +22 -18
  2. package/dist/api/index.d.cts +16 -8
  3. package/dist/api/index.d.ts +16 -8
  4. package/dist/api/index.js +1 -1
  5. package/dist/{buy-now-B1dkx82V.d.cts → buy-now-BqVWXyy8.d.cts} +1 -1
  6. package/dist/{buy-now-BgKd5p4J.d.ts → buy-now-DFdnuLjO.d.ts} +1 -1
  7. package/dist/{cart-BGIsIZdM.d.ts → cart-DZq1ZEnE.d.ts} +1 -1
  8. package/dist/{cart-CyN2JQTw.d.cts → cart-DwMFBmpC.d.cts} +1 -1
  9. package/dist/checkout/index.cjs +21 -21
  10. package/dist/checkout/index.d.cts +3 -3
  11. package/dist/checkout/index.d.ts +3 -3
  12. package/dist/checkout/index.js +2 -2
  13. package/dist/{chunk-TFWTQTWE.cjs → chunk-34Y7Y5FU.cjs} +12 -12
  14. package/dist/{chunk-CIBMO44U.cjs → chunk-NOT6VKXA.cjs} +18 -15
  15. package/dist/{chunk-ETXIP5XE.cjs → chunk-NRPK5GCJ.cjs} +8 -0
  16. package/dist/{chunk-K44JZ5NL.cjs → chunk-NSAHGMS7.cjs} +6 -1
  17. package/dist/{chunk-SU5LVRZD.js → chunk-QQHQTBAM.js} +12 -9
  18. package/dist/{chunk-WFDKKOO7.js → chunk-VAU5OL72.js} +6 -1
  19. package/dist/{chunk-UWW5YIHL.js → chunk-VPTN4YXD.js} +1 -1
  20. package/dist/{chunk-YMZZCVZ2.js → chunk-ZAWZ3RB6.js} +8 -1
  21. package/dist/{collections-ycrA2cPL.d.ts → collections-CNh2OGbl.d.ts} +1 -1
  22. package/dist/{collections-8YdINtUf.d.cts → collections-CXgOv5_G.d.cts} +1 -1
  23. package/dist/components/digital-product-download-modal.d.cts +2 -2
  24. package/dist/components/digital-product-download-modal.d.ts +2 -2
  25. package/dist/components/index.d.cts +5 -5
  26. package/dist/components/index.d.ts +5 -5
  27. package/dist/components/share-button.d.cts +1 -1
  28. package/dist/components/share-button.d.ts +1 -1
  29. package/dist/components/theme-data-initializer.d.cts +5 -5
  30. package/dist/components/theme-data-initializer.d.ts +5 -5
  31. package/dist/hooks/index.cjs +47 -20
  32. package/dist/hooks/index.d.cts +6 -5
  33. package/dist/hooks/index.d.ts +6 -5
  34. package/dist/hooks/index.js +32 -5
  35. package/dist/{instagram-CqJBZ-0X.d.ts → instagram-BADLnNQ3.d.ts} +1 -1
  36. package/dist/{instagram-D4JUT4ZU.d.cts → instagram-DalreBu6.d.cts} +1 -1
  37. package/dist/models/index.d.cts +7 -7
  38. package/dist/models/index.d.ts +7 -7
  39. package/dist/{orders-COKWr7K7.d.cts → orders-B3G4CyhH.d.cts} +1 -1
  40. package/dist/{orders-Cp8qNCrl.d.ts → orders-Bl-Slh72.d.ts} +1 -1
  41. package/dist/{pixelEvents-BJNH06rS.d.cts → pixelEvents-BtEO5QAR.d.cts} +4 -4
  42. package/dist/{pixelEvents-2Tb-_fRP.d.ts → pixelEvents-LsealscG.d.ts} +4 -4
  43. package/dist/{product-CZtFWhxO.d.ts → product-D9liEtl4.d.cts} +1 -0
  44. package/dist/{product-CZtFWhxO.d.cts → product-D9liEtl4.d.ts} +1 -0
  45. package/dist/store/index.cjs +7 -7
  46. package/dist/store/index.d.cts +6 -6
  47. package/dist/store/index.d.ts +6 -6
  48. package/dist/store/index.js +2 -2
  49. package/dist/utils/index.cjs +2 -2
  50. package/dist/utils/index.d.cts +7 -7
  51. package/dist/utils/index.d.ts +7 -7
  52. package/dist/utils/index.js +1 -1
  53. package/dist/{wishlist-Cx9Vrszq.d.cts → wishlist-BakHvIFN.d.cts} +1 -1
  54. package/dist/{wishlist-CRNbfFIx.d.ts → wishlist-Cj0sQxiY.d.ts} +1 -1
  55. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { updateCart, removeFromCart, addToCart, getCart, getCartItemQuantity } from './chunk-YMZZCVZ2.js';
1
+ import { updateCart, removeFromCart, addToCart, getCart, getCartItemQuantity, mergeCart } from './chunk-ZAWZ3RB6.js';
2
2
  import { cart_default } from './chunk-TH7OAMGC.js';
3
3
  import { updateOrderCustomization } from './chunk-KCLVR6G5.js';
4
4
  import { auth_default } from './chunk-WEMNXIRS.js';
@@ -169,14 +169,7 @@ var useAuthStore = create((set, get) => ({
169
169
  set({ user, status: "success" /* SUCCESS */, isAuthenticated: true });
170
170
  const localCartItems = cart_default.get();
171
171
  if (localCartItems) {
172
- await useCartStore.getState().addToCart(
173
- Object.entries(localCartItems.products_quantity).map(
174
- ([key, value]) => ({
175
- variant_id: parseInt(key),
176
- quantity: value
177
- })
178
- )
179
- );
172
+ await mergeLocalCart(localCartItems);
180
173
  cart_default.clear();
181
174
  await useCartStore.getState().fetchCart();
182
175
  setTimeout(() => {
@@ -208,6 +201,16 @@ var useAuthStore = create((set, get) => ({
208
201
  }, 1e3);
209
202
  }
210
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
+ }
211
214
  var loginUser = async (user) => {
212
215
  const { access, refresh, ...userData } = user;
213
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,5 +1,5 @@
1
1
  import { getCoupons, getAppliedCoupon, applyCoupon, removeCoupon } from './chunk-7M5CVYZJ.js';
2
- import { pixelEvents } from './chunk-WFDKKOO7.js';
2
+ import { pixelEvents } from './chunk-VAU5OL72.js';
3
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';
@@ -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,4 +1,4 @@
1
- import { d as Product } from './product-CZtFWhxO.js';
1
+ import { d as Product } from './product-D9liEtl4.js';
2
2
 
3
3
  interface CollectionResponse {
4
4
  id: number;
@@ -1,4 +1,4 @@
1
- import { d as Product } from './product-CZtFWhxO.cjs';
1
+ import { d as Product } from './product-D9liEtl4.cjs';
2
2
 
3
3
  interface CollectionResponse {
4
4
  id: number;
@@ -1,5 +1,5 @@
1
- import { O as Order } from '../orders-COKWr7K7.cjs';
2
- import { f as ProductDetail } from '../product-CZtFWhxO.cjs';
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-Cp8qNCrl.js';
2
- import { f as ProductDetail } from '../product-CZtFWhxO.js';
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 {
@@ -8,10 +8,10 @@ import 'react';
8
8
  import '../useAddressForm-DGbEn91-.cjs';
9
9
  import 'formik';
10
10
  import '../address-DwBZHzbI.cjs';
11
- import '../product-CZtFWhxO.cjs';
11
+ import '../product-D9liEtl4.cjs';
12
12
  import 'react-toastify';
13
13
  import 'react/jsx-runtime';
14
- import '../orders-COKWr7K7.cjs';
15
- import '../pixelEvents-BJNH06rS.cjs';
16
- import '../cart-CyN2JQTw.cjs';
17
- import '../collections-8YdINtUf.cjs';
14
+ import '../orders-B3G4CyhH.cjs';
15
+ import '../pixelEvents-BtEO5QAR.cjs';
16
+ import '../cart-DwMFBmpC.cjs';
17
+ import '../collections-CXgOv5_G.cjs';
@@ -8,10 +8,10 @@ import 'react';
8
8
  import '../useAddressForm-cO3Au33k.js';
9
9
  import 'formik';
10
10
  import '../address-DwBZHzbI.js';
11
- import '../product-CZtFWhxO.js';
11
+ import '../product-D9liEtl4.js';
12
12
  import 'react-toastify';
13
13
  import 'react/jsx-runtime';
14
- import '../orders-Cp8qNCrl.js';
15
- import '../pixelEvents-2Tb-_fRP.js';
16
- import '../cart-BGIsIZdM.js';
17
- import '../collections-ycrA2cPL.js';
14
+ import '../orders-Bl-Slh72.js';
15
+ import '../pixelEvents-LsealscG.js';
16
+ import '../cart-DZq1ZEnE.js';
17
+ import '../collections-CNh2OGbl.js';
@@ -1,4 +1,4 @@
1
- import { f as ProductDetail } from '../product-CZtFWhxO.cjs';
1
+ import { f as ProductDetail } from '../product-D9liEtl4.cjs';
2
2
  import 'react-toastify';
3
3
 
4
4
  interface ShareButtonProps {
@@ -1,4 +1,4 @@
1
- import { f as ProductDetail } from '../product-CZtFWhxO.js';
1
+ import { f as ProductDetail } from '../product-D9liEtl4.js';
2
2
  import 'react-toastify';
3
3
 
4
4
  interface ShareButtonProps {
@@ -1,9 +1,9 @@
1
- import { P as PageHeaderProps } from '../pixelEvents-BJNH06rS.cjs';
2
- import '../cart-CyN2JQTw.cjs';
3
- import '../product-CZtFWhxO.cjs';
1
+ import { P as PageHeaderProps } from '../pixelEvents-BtEO5QAR.cjs';
2
+ import '../cart-DwMFBmpC.cjs';
3
+ import '../product-D9liEtl4.cjs';
4
4
  import 'react-toastify';
5
- import '../collections-8YdINtUf.cjs';
6
- import '../orders-COKWr7K7.cjs';
5
+ import '../collections-CXgOv5_G.cjs';
6
+ import '../orders-B3G4CyhH.cjs';
7
7
 
8
8
  declare function ThemeDataInitializer({ themeData, }: {
9
9
  themeData: PageHeaderProps;
@@ -1,9 +1,9 @@
1
- import { P as PageHeaderProps } from '../pixelEvents-2Tb-_fRP.js';
2
- import '../cart-BGIsIZdM.js';
3
- import '../product-CZtFWhxO.js';
1
+ import { P as PageHeaderProps } from '../pixelEvents-LsealscG.js';
2
+ import '../cart-DZq1ZEnE.js';
3
+ import '../product-D9liEtl4.js';
4
4
  import 'react-toastify';
5
- import '../collections-ycrA2cPL.js';
6
- import '../orders-Cp8qNCrl.js';
5
+ import '../collections-CNh2OGbl.js';
6
+ import '../orders-Bl-Slh72.js';
7
7
 
8
8
  declare function ThemeDataInitializer({ themeData, }: {
9
9
  themeData: PageHeaderProps;
@@ -2,12 +2,12 @@
2
2
 
3
3
  var chunkY46EHRJQ_cjs = require('../chunk-Y46EHRJQ.cjs');
4
4
  var chunk2AHH3XBW_cjs = require('../chunk-2AHH3XBW.cjs');
5
- var chunkCIBMO44U_cjs = require('../chunk-CIBMO44U.cjs');
6
- var chunkETXIP5XE_cjs = require('../chunk-ETXIP5XE.cjs');
5
+ var chunkNOT6VKXA_cjs = require('../chunk-NOT6VKXA.cjs');
6
+ var chunkNRPK5GCJ_cjs = require('../chunk-NRPK5GCJ.cjs');
7
7
  var chunkNQZ5GUOG_cjs = require('../chunk-NQZ5GUOG.cjs');
8
- var chunkTFWTQTWE_cjs = require('../chunk-TFWTQTWE.cjs');
8
+ var chunk34Y7Y5FU_cjs = require('../chunk-34Y7Y5FU.cjs');
9
9
  var chunkXFOUNOKO_cjs = require('../chunk-XFOUNOKO.cjs');
10
- require('../chunk-K44JZ5NL.cjs');
10
+ require('../chunk-NSAHGMS7.cjs');
11
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');
@@ -56,7 +56,7 @@ var useCart = (addressId) => {
56
56
  async (addrId, shippingId) => {
57
57
  try {
58
58
  setIsLoading(true);
59
- const result = await chunkETXIP5XE_cjs.getCart("/customer/cart/", addrId ?? addressId, shippingId);
59
+ const result = await chunkNRPK5GCJ_cjs.getCart("/customer/cart/", addrId ?? addressId, shippingId);
60
60
  setData(result);
61
61
  setError(null);
62
62
  } catch (err) {
@@ -128,7 +128,7 @@ function useGetProducts(initialFilter, options) {
128
128
  apiParams[key] = value;
129
129
  }
130
130
  }
131
- const result = await chunkETXIP5XE_cjs.getProductList(endpoint, apiParams);
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 chunkETXIP5XE_cjs.getProductDetail("/inventory/products/", slug);
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 chunkETXIP5XE_cjs.getProductCategories("/store/categories");
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 chunkETXIP5XE_cjs.getWishlist("/customer/wishlist/");
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 = chunkCIBMO44U_cjs.useCartStore((s) => s.resetCartCount);
325
+ const resetCartCount = chunkNOT6VKXA_cjs.useCartStore((s) => s.resetCartCount);
326
326
  const callbacks = {
327
327
  onSuccess: (order) => {
328
328
  setOrderSummary(order);
@@ -355,7 +355,7 @@ function useCheckoutPayment(options) {
355
355
  );
356
356
  const order = response.data;
357
357
  setOrderSummary(order);
358
- chunkTFWTQTWE_cjs.processPayment(order, paymentMethod, callbacks);
358
+ chunk34Y7Y5FU_cjs.processPayment(order, paymentMethod, callbacks);
359
359
  } catch (error) {
360
360
  if (options.onPlaceOrderError?.(error) === true) return;
361
361
  setShowFailureModal(true);
@@ -413,7 +413,7 @@ function useBuyNow(isAuthenticated = true) {
413
413
  const [quantity, setQuantityState] = react.useState(1);
414
414
  const [couponCodes, setCouponCodes] = react.useState(void 0);
415
415
  const [addressId, setAddressIdState] = react.useState(void 0);
416
- const [guestAddress, setGuestAddress] = react.useState(void 0);
416
+ const [guestAddress, setGuestAddressState] = react.useState(void 0);
417
417
  const [shippingOptionId, setShippingOptionIdState] = react.useState(void 0);
418
418
  const [preview, setPreview] = react.useState(null);
419
419
  const [isLoading, setIsLoading] = react.useState(true);
@@ -488,6 +488,14 @@ function useBuyNow(isAuthenticated = true) {
488
488
  setAddressIdState(id);
489
489
  setShippingOptionIdState(void 0);
490
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
+ }, []);
491
499
  const setShippingOptionId = react.useCallback((id) => {
492
500
  setShippingOptionIdState(id);
493
501
  }, []);
@@ -628,7 +636,7 @@ function useInlineCheckoutPayment(options) {
628
636
  return;
629
637
  }
630
638
  setOrderSummary(order);
631
- chunkTFWTQTWE_cjs.processPayment(order, paymentMethod, callbacks, { isPublic });
639
+ chunk34Y7Y5FU_cjs.processPayment(order, paymentMethod, callbacks, { isPublic });
632
640
  } catch (error) {
633
641
  if (options.onPlaceOrderError?.(error) === true) return;
634
642
  setShowFailureModal(true);
@@ -910,7 +918,7 @@ function useCheckoutCoupon(options) {
910
918
  const refreshCoupons = react.useCallback(async () => {
911
919
  setIsLoading(true);
912
920
  try {
913
- const coupons = await chunkTFWTQTWE_cjs.fetchAvailableCoupons();
921
+ const coupons = await chunk34Y7Y5FU_cjs.fetchAvailableCoupons();
914
922
  setAvailableCoupons(coupons);
915
923
  } catch {
916
924
  } finally {
@@ -922,7 +930,7 @@ function useCheckoutCoupon(options) {
922
930
  setError(null);
923
931
  setIsApplying(true);
924
932
  try {
925
- const coupon = await chunkTFWTQTWE_cjs.applyCheckoutCoupon(code, callbacks);
933
+ const coupon = await chunk34Y7Y5FU_cjs.applyCheckoutCoupon(code, callbacks);
926
934
  setAppliedCoupon(coupon);
927
935
  } catch (err) {
928
936
  setError(err instanceof Error ? err.message : "Failed to apply coupon");
@@ -935,7 +943,7 @@ function useCheckoutCoupon(options) {
935
943
  const removeCouponHandler = react.useCallback(async () => {
936
944
  if (!appliedCoupon) return;
937
945
  try {
938
- await chunkTFWTQTWE_cjs.removeCheckoutCoupon(appliedCoupon.coupon_code, callbacks);
946
+ await chunk34Y7Y5FU_cjs.removeCheckoutCoupon(appliedCoupon.coupon_code, callbacks);
939
947
  setAppliedCoupon(null);
940
948
  setError(null);
941
949
  } catch {
@@ -1034,8 +1042,9 @@ function useVariantSelector(options) {
1034
1042
  }
1035
1043
  function useShopCheckout(options) {
1036
1044
  const { product, onNavigateToCart, onToast, onPreorderRejected } = options;
1037
- const { addToCart, setCart } = chunkCIBMO44U_cjs.useCartStore();
1038
- const isUserAuthenticated = chunkCIBMO44U_cjs.useAuthStore((s) => s.isAuthenticated);
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);
1039
1048
  const [isWishlisted, setIsWishlisted] = react.useState(product.is_wishlisted);
1040
1049
  const [isAddedToCart, setIsAddedToCart] = react.useState(false);
1041
1050
  const [loading, setLoading] = react.useState(false);
@@ -1043,10 +1052,27 @@ function useShopCheckout(options) {
1043
1052
  const [showLoginModal, setShowLoginModal] = react.useState(false);
1044
1053
  const [showNotifyMeModal, setShowNotifyMeModal] = react.useState(false);
1045
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]);
1046
1072
  react.useEffect(() => {
1047
1073
  const fetchCategories = async () => {
1048
1074
  try {
1049
- const response = await chunkETXIP5XE_cjs.getCategories();
1075
+ const response = await chunkNRPK5GCJ_cjs.getCategories();
1050
1076
  setCategories(response.data);
1051
1077
  } catch (error) {
1052
1078
  console.log(error);
@@ -1166,7 +1192,7 @@ function useShopCheckout(options) {
1166
1192
  const handleNotifyMeFormSubmit = react.useCallback(
1167
1193
  async (values) => {
1168
1194
  try {
1169
- const response = await chunkETXIP5XE_cjs.notifyProductStock({
1195
+ const response = await chunkNRPK5GCJ_cjs.notifyProductStock({
1170
1196
  ...values,
1171
1197
  variant_slug: product.slug
1172
1198
  });
@@ -1196,6 +1222,7 @@ function useShopCheckout(options) {
1196
1222
  return {
1197
1223
  isWishlisted,
1198
1224
  isAddedToCart,
1225
+ cartQuantity,
1199
1226
  loading,
1200
1227
  quantity,
1201
1228
  showLoginModal,
@@ -1,10 +1,10 @@
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-CyN2JQTw.cjs';
4
- import { O as Order } from '../orders-COKWr7K7.cjs';
5
- import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-CZtFWhxO.cjs';
6
- import { W as Wishlist } from '../wishlist-Cx9Vrszq.cjs';
7
- import { C as Checkout, B as BuyNow, P as PublicCheckout } from '../buy-now-B1dkx82V.cjs';
3
+ import { C as Cart, b as Category, U as User, c as Coupon } from '../cart-DwMFBmpC.cjs';
4
+ import { O as Order } from '../orders-B3G4CyhH.cjs';
5
+ import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-D9liEtl4.cjs';
6
+ import { W as Wishlist } from '../wishlist-BakHvIFN.cjs';
7
+ import { C as Checkout, B as BuyNow, P as PublicCheckout } from '../buy-now-BqVWXyy8.cjs';
8
8
  export { U as UseAddressFormOptions, a as UseAddressFormReturn, u as useAddressForm } from '../useAddressForm-DGbEn91-.cjs';
9
9
  import 'react-toastify';
10
10
  import 'formik';
@@ -355,6 +355,7 @@ interface UseShopCheckoutOptions {
355
355
  interface UseShopCheckoutReturn {
356
356
  isWishlisted: boolean;
357
357
  isAddedToCart: boolean;
358
+ cartQuantity: number;
358
359
  loading: boolean;
359
360
  quantity: number;
360
361
  showLoginModal: boolean;
@@ -1,10 +1,10 @@
1
1
  import { A as Address } from '../address-DwBZHzbI.js';
2
2
  import * as React from 'react';
3
- import { C as Cart, b as Category, U as User, c as Coupon } from '../cart-BGIsIZdM.js';
4
- import { O as Order } from '../orders-Cp8qNCrl.js';
5
- import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-CZtFWhxO.js';
6
- import { W as Wishlist } from '../wishlist-CRNbfFIx.js';
7
- import { C as Checkout, B as BuyNow, P as PublicCheckout } from '../buy-now-BgKd5p4J.js';
3
+ import { C as Cart, b as Category, U as User, c as Coupon } from '../cart-DZq1ZEnE.js';
4
+ import { O as Order } from '../orders-Bl-Slh72.js';
5
+ import { d as Product, f as ProductDetail, e as ProductAttribute, A as Attributes } from '../product-D9liEtl4.js';
6
+ import { W as Wishlist } from '../wishlist-Cj0sQxiY.js';
7
+ import { C as Checkout, B as BuyNow, P as PublicCheckout } from '../buy-now-DFdnuLjO.js';
8
8
  export { U as UseAddressFormOptions, a as UseAddressFormReturn, u as useAddressForm } from '../useAddressForm-cO3Au33k.js';
9
9
  import 'react-toastify';
10
10
  import 'formik';
@@ -355,6 +355,7 @@ interface UseShopCheckoutOptions {
355
355
  interface UseShopCheckoutReturn {
356
356
  isWishlisted: boolean;
357
357
  isAddedToCart: boolean;
358
+ cartQuantity: number;
358
359
  loading: boolean;
359
360
  quantity: number;
360
361
  showLoginModal: boolean;
@@ -1,11 +1,11 @@
1
1
  import { getUserDetails } from '../chunk-WYXT5AAG.js';
2
2
  import { findMatchingVariant, findSimilarVariant, isVariantCombinationAvailable, isColorVariantType } from '../chunk-HEFA67WK.js';
3
- import { useCartStore, useAuthStore } from '../chunk-SU5LVRZD.js';
4
- import { getCart, getProductList, getProductDetail, getWishlist, notifyProductStock, getProductCategories, getCategories } from '../chunk-YMZZCVZ2.js';
3
+ import { useCartStore, useAuthStore } from '../chunk-QQHQTBAM.js';
4
+ import { getCart, getProductList, getProductDetail, getWishlist, notifyProductStock, getProductCategories, getCategories } from '../chunk-ZAWZ3RB6.js';
5
5
  import { cart_default } from '../chunk-TH7OAMGC.js';
6
- import { processPayment, fetchAvailableCoupons, applyCheckoutCoupon, removeCheckoutCoupon } from '../chunk-UWW5YIHL.js';
6
+ import { processPayment, fetchAvailableCoupons, applyCheckoutCoupon, removeCheckoutCoupon } from '../chunk-VPTN4YXD.js';
7
7
  import { applyCoupon, removeCoupon, getCoupons, getAppliedCoupon } from '../chunk-7M5CVYZJ.js';
8
- import '../chunk-WFDKKOO7.js';
8
+ import '../chunk-VAU5OL72.js';
9
9
  import { getOrders, placeOrder, buyNowPreview, placeGuestBuyNowOrder, placeBuyNowOrder, publicCheckoutPreview, placePublicOrder } from '../chunk-KCLVR6G5.js';
10
10
  export { useAddressForm } from '../chunk-ICKTXS6B.js';
11
11
  import { getAddresses } from '../chunk-ZGMLOLTC.js';
@@ -411,7 +411,7 @@ function useBuyNow(isAuthenticated = true) {
411
411
  const [quantity, setQuantityState] = useState(1);
412
412
  const [couponCodes, setCouponCodes] = useState(void 0);
413
413
  const [addressId, setAddressIdState] = useState(void 0);
414
- const [guestAddress, setGuestAddress] = useState(void 0);
414
+ const [guestAddress, setGuestAddressState] = useState(void 0);
415
415
  const [shippingOptionId, setShippingOptionIdState] = useState(void 0);
416
416
  const [preview, setPreview] = useState(null);
417
417
  const [isLoading, setIsLoading] = useState(true);
@@ -486,6 +486,14 @@ function useBuyNow(isAuthenticated = true) {
486
486
  setAddressIdState(id);
487
487
  setShippingOptionIdState(void 0);
488
488
  }, []);
489
+ const setGuestAddress = useCallback((address) => {
490
+ const prev = stateRef.current.guestAddress;
491
+ const unchanged = prev?.country_obj === address?.country_obj && prev?.state_obj === address?.state_obj && prev?.pincode === address?.pincode;
492
+ if (unchanged) return;
493
+ const destinationChanged = prev?.country_obj !== address?.country_obj || prev?.state_obj !== address?.state_obj;
494
+ setGuestAddressState(address);
495
+ if (destinationChanged) setShippingOptionIdState(void 0);
496
+ }, []);
489
497
  const setShippingOptionId = useCallback((id) => {
490
498
  setShippingOptionIdState(id);
491
499
  }, []);
@@ -1033,6 +1041,7 @@ function useVariantSelector(options) {
1033
1041
  function useShopCheckout(options) {
1034
1042
  const { product, onNavigateToCart, onToast, onPreorderRejected } = options;
1035
1043
  const { addToCart, setCart } = useCartStore();
1044
+ const cart = useCartStore((s) => s.cart);
1036
1045
  const isUserAuthenticated = useAuthStore((s) => s.isAuthenticated);
1037
1046
  const [isWishlisted, setIsWishlisted] = useState(product.is_wishlisted);
1038
1047
  const [isAddedToCart, setIsAddedToCart] = useState(false);
@@ -1041,6 +1050,23 @@ function useShopCheckout(options) {
1041
1050
  const [showLoginModal, setShowLoginModal] = useState(false);
1042
1051
  const [showNotifyMeModal, setShowNotifyMeModal] = useState(false);
1043
1052
  const [categories, setCategories] = useState([]);
1053
+ const [cartQuantity, setCartQuantity] = useState(
1054
+ Number(product.cart_quantity) || 0
1055
+ );
1056
+ useEffect(() => {
1057
+ let inCart;
1058
+ if (!isUserAuthenticated) {
1059
+ inCart = Number(cart_default.get()?.products_quantity?.[product.id]) || 0;
1060
+ } else if (cart) {
1061
+ inCart = cart.total_quantity > 0 ? Number(cart.products_quantity?.[product.id]) || 0 : 0;
1062
+ } else if (product.cart_quantity !== void 0) {
1063
+ inCart = Number(product.cart_quantity) || 0;
1064
+ }
1065
+ if (inCart !== void 0) {
1066
+ setCartQuantity(inCart);
1067
+ setIsAddedToCart(inCart > 0);
1068
+ }
1069
+ }, [product.id, product.cart_quantity, cart, isUserAuthenticated]);
1044
1070
  useEffect(() => {
1045
1071
  const fetchCategories = async () => {
1046
1072
  try {
@@ -1194,6 +1220,7 @@ function useShopCheckout(options) {
1194
1220
  return {
1195
1221
  isWishlisted,
1196
1222
  isAddedToCart,
1223
+ cartQuantity,
1197
1224
  loading,
1198
1225
  quantity,
1199
1226
  showLoginModal,
@@ -1,4 +1,4 @@
1
- import { f as ProductDetail } from './product-CZtFWhxO.js';
1
+ import { f as ProductDetail } from './product-D9liEtl4.js';
2
2
 
3
3
  declare namespace Review {
4
4
  interface ReviewPayload {
@@ -1,4 +1,4 @@
1
- import { f as ProductDetail } from './product-CZtFWhxO.cjs';
1
+ import { f as ProductDetail } from './product-D9liEtl4.cjs';
2
2
 
3
3
  declare namespace Review {
4
4
  interface ReviewPayload {
@@ -1,12 +1,12 @@
1
1
  export { A as Address } from '../address-DwBZHzbI.cjs';
2
- export { A as Analytics, B as Blog, a as Booking, b as BookingDetails, I as Instagram, R as Review } from '../instagram-D4JUT4ZU.cjs';
3
- export { B as BuyNow, C as Checkout, P as PublicCheckout } from '../buy-now-B1dkx82V.cjs';
4
- export { A as ApplicableTarget, C as Cart, a as CartState, b as Category, c as Coupon, d as CouponResponse, e as CouponStatus, f as Coupons, D as DiscountType, U as User, V as ValueType } from '../cart-CyN2JQTw.cjs';
5
- export { A as CollectionAttributes, C as CollectionResponse, s as singleCollection } from '../collections-8YdINtUf.cjs';
6
- export { O as Order } from '../orders-COKWr7K7.cjs';
2
+ export { A as Analytics, B as Blog, a as Booking, b as BookingDetails, I as Instagram, R as Review } from '../instagram-DalreBu6.cjs';
3
+ export { B as BuyNow, C as Checkout, P as PublicCheckout } from '../buy-now-BqVWXyy8.cjs';
4
+ export { A as ApplicableTarget, C as Cart, a as CartState, b as Category, c as Coupon, d as CouponResponse, e as CouponStatus, f as Coupons, D as DiscountType, U as User, V as ValueType } from '../cart-DwMFBmpC.cjs';
5
+ export { A as CollectionAttributes, C as CollectionResponse, s as singleCollection } from '../collections-CXgOv5_G.cjs';
6
+ export { O as Order } from '../orders-B3G4CyhH.cjs';
7
7
  export { D as Data, P as PaymentInstrument, a as PhonePe } from '../phonepe-dWMLZel6.cjs';
8
- export { A as Attributes, B as BaseProduct, a as BookingService, b as BookingServiceDate, c as Brand, C as CustomField, O as OperatingHours, P as Photos, d as Product, e as ProductAttribute, f as ProductDetail, S as SpecialHours, T as TimeSlot, W as WishlistState } from '../product-CZtFWhxO.cjs';
9
- export { W as Wishlist } from '../wishlist-Cx9Vrszq.cjs';
8
+ export { A as Attributes, B as BaseProduct, a as BookingService, b as BookingServiceDate, c as Brand, C as CustomField, O as OperatingHours, P as Photos, d as Product, e as ProductAttribute, f as ProductDetail, S as SpecialHours, T as TimeSlot, W as WishlistState } from '../product-D9liEtl4.cjs';
9
+ export { W as Wishlist } from '../wishlist-BakHvIFN.cjs';
10
10
  import 'react-toastify';
11
11
 
12
12
  declare namespace CountryModel {
@@ -1,12 +1,12 @@
1
1
  export { A as Address } from '../address-DwBZHzbI.js';
2
- export { A as Analytics, B as Blog, a as Booking, b as BookingDetails, I as Instagram, R as Review } from '../instagram-CqJBZ-0X.js';
3
- export { B as BuyNow, C as Checkout, P as PublicCheckout } from '../buy-now-BgKd5p4J.js';
4
- export { A as ApplicableTarget, C as Cart, a as CartState, b as Category, c as Coupon, d as CouponResponse, e as CouponStatus, f as Coupons, D as DiscountType, U as User, V as ValueType } from '../cart-BGIsIZdM.js';
5
- export { A as CollectionAttributes, C as CollectionResponse, s as singleCollection } from '../collections-ycrA2cPL.js';
6
- export { O as Order } from '../orders-Cp8qNCrl.js';
2
+ export { A as Analytics, B as Blog, a as Booking, b as BookingDetails, I as Instagram, R as Review } from '../instagram-BADLnNQ3.js';
3
+ export { B as BuyNow, C as Checkout, P as PublicCheckout } from '../buy-now-DFdnuLjO.js';
4
+ export { A as ApplicableTarget, C as Cart, a as CartState, b as Category, c as Coupon, d as CouponResponse, e as CouponStatus, f as Coupons, D as DiscountType, U as User, V as ValueType } from '../cart-DZq1ZEnE.js';
5
+ export { A as CollectionAttributes, C as CollectionResponse, s as singleCollection } from '../collections-CNh2OGbl.js';
6
+ export { O as Order } from '../orders-Bl-Slh72.js';
7
7
  export { D as Data, P as PaymentInstrument, a as PhonePe } from '../phonepe-dWMLZel6.js';
8
- export { A as Attributes, B as BaseProduct, a as BookingService, b as BookingServiceDate, c as Brand, C as CustomField, O as OperatingHours, P as Photos, d as Product, e as ProductAttribute, f as ProductDetail, S as SpecialHours, T as TimeSlot, W as WishlistState } from '../product-CZtFWhxO.js';
9
- export { W as Wishlist } from '../wishlist-CRNbfFIx.js';
8
+ export { A as Attributes, B as BaseProduct, a as BookingService, b as BookingServiceDate, c as Brand, C as CustomField, O as OperatingHours, P as Photos, d as Product, e as ProductAttribute, f as ProductDetail, S as SpecialHours, T as TimeSlot, W as WishlistState } from '../product-D9liEtl4.js';
9
+ export { W as Wishlist } from '../wishlist-Cj0sQxiY.js';
10
10
  import 'react-toastify';
11
11
 
12
12
  declare namespace CountryModel {
@@ -1,4 +1,4 @@
1
- import { P as Photos } from './product-CZtFWhxO.cjs';
1
+ import { P as Photos } from './product-D9liEtl4.cjs';
2
2
 
3
3
  declare namespace Order {
4
4
  interface Root {
@@ -1,4 +1,4 @@
1
- import { P as Photos } from './product-CZtFWhxO.js';
1
+ import { P as Photos } from './product-D9liEtl4.js';
2
2
 
3
3
  declare namespace Order {
4
4
  interface Root {
@@ -1,7 +1,7 @@
1
- import { b as Category$1, C as Cart } from './cart-CyN2JQTw.cjs';
2
- import { C as CollectionResponse } from './collections-8YdINtUf.cjs';
3
- import { O as Order } from './orders-COKWr7K7.cjs';
4
- import { f as ProductDetail, d as Product } from './product-CZtFWhxO.cjs';
1
+ import { b as Category$1, C as Cart } from './cart-DwMFBmpC.cjs';
2
+ import { C as CollectionResponse } from './collections-CXgOv5_G.cjs';
3
+ import { O as Order } from './orders-B3G4CyhH.cjs';
4
+ import { f as ProductDetail, d as Product } from './product-D9liEtl4.cjs';
5
5
 
6
6
  interface PageProps {
7
7
  nav_bar: NavBar;