@storepecker/storefront-core 2.9.1 → 2.10.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/address-BdIB6IuI.d.cts +42 -0
- package/dist/address-BdIB6IuI.d.ts +42 -0
- package/dist/api/index.cjs +36 -32
- package/dist/api/index.d.cts +20 -17
- package/dist/api/index.d.ts +20 -17
- package/dist/api/index.js +4 -4
- package/dist/{buy-now-BqVWXyy8.d.cts → buy-now-CDug6LJ_.d.ts} +2 -2
- package/dist/{buy-now-DFdnuLjO.d.ts → buy-now-DrKY5_9R.d.cts} +2 -2
- package/dist/checkout/index.cjs +163 -76
- package/dist/checkout/index.d.cts +37 -26
- package/dist/checkout/index.d.ts +37 -26
- package/dist/checkout/index.js +50 -64
- package/dist/checkout-totals-CbmXM9L7.d.cts +220 -0
- package/dist/checkout-totals-DU8l-Wyb.d.ts +220 -0
- package/dist/{chunk-IG4BW3ZB.cjs → chunk-32X4SWN4.cjs} +3 -3
- package/dist/{chunk-NQZ5GUOG.cjs → chunk-3YPE6UPC.cjs} +24 -16
- package/dist/{chunk-RDUT4W3B.cjs → chunk-6APRQ2ED.cjs} +4 -1
- package/dist/{chunk-ICKTXS6B.js → chunk-6IXTFZFS.js} +3 -3
- package/dist/{chunk-7M5CVYZJ.js → chunk-A7EI7XLU.js} +8 -1
- package/dist/chunk-DZPK7GPG.js +601 -0
- package/dist/{chunk-TH7OAMGC.js → chunk-E4D4XOAE.js} +24 -16
- package/dist/{chunk-NRPK5GCJ.cjs → chunk-EFYAFXIS.cjs} +3 -3
- package/dist/{chunk-CBKJ3Y2I.js → chunk-EWZ7TGI7.js} +11 -1
- package/dist/{chunk-5XVHYPOC.js → chunk-FF5N7PTB.js} +1 -1
- package/dist/{chunk-NOT6VKXA.cjs → chunk-H6UZTS5O.cjs} +67 -23
- package/dist/{chunk-XFOUNOKO.cjs → chunk-KNG4OMS5.cjs} +8 -0
- package/dist/{chunk-ZAWZ3RB6.js → chunk-NNE42NMP.js} +1 -1
- package/dist/chunk-PN6KH5PX.cjs +661 -0
- package/dist/{chunk-QQHQTBAM.js → chunk-QSRVMOXT.js} +48 -6
- package/dist/{chunk-W6BDMNSU.js → chunk-QVO56X4E.js} +1 -1
- package/dist/{chunk-6LS5F4R3.cjs → chunk-SGJUMI3M.cjs} +11 -0
- package/dist/{chunk-YLLAP3H2.cjs → chunk-SGKLMS7W.cjs} +2 -2
- package/dist/{chunk-ZGMLOLTC.js → chunk-VRZRV2BR.js} +4 -1
- package/dist/{chunk-IVKJJLG7.cjs → chunk-WWJAPKRQ.cjs} +8 -8
- package/dist/{collections-CXgOv5_G.d.cts → collections-CKNFcE2d.d.cts} +1 -1
- package/dist/{collections-CNh2OGbl.d.ts → collections-CtRKsWVx.d.ts} +1 -1
- package/dist/components/address-form.cjs +6 -6
- package/dist/components/address-form.d.cts +10 -6
- package/dist/components/address-form.d.ts +10 -6
- package/dist/components/address-form.js +5 -5
- 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.cjs +8 -8
- package/dist/components/index.d.cts +6 -7
- package/dist/components/index.d.ts +6 -7
- package/dist/components/index.js +6 -6
- package/dist/components/search-dropdown.d.cts +4 -4
- package/dist/components/search-dropdown.d.ts +4 -4
- package/dist/components/share-button.cjs +3 -3
- package/dist/components/share-button.d.cts +1 -1
- package/dist/components/share-button.d.ts +1 -1
- package/dist/components/share-button.js +2 -2
- package/dist/components/theme-data-initializer.d.cts +4 -5
- package/dist/components/theme-data-initializer.d.ts +4 -5
- package/dist/hooks/index.cjs +672 -44
- package/dist/hooks/index.d.cts +239 -13
- package/dist/hooks/index.d.ts +239 -13
- package/dist/hooks/index.js +630 -11
- package/dist/{instagram-DalreBu6.d.cts → instagram-CSzrxk10.d.cts} +8 -2
- package/dist/{instagram-BADLnNQ3.d.ts → instagram-CagTLmyq.d.ts} +8 -2
- package/dist/models/index.d.cts +8 -8
- package/dist/models/index.d.ts +8 -8
- package/dist/orders-B6BmHCJN.d.ts +337 -0
- package/dist/orders-ZKP0lqRN.d.cts +337 -0
- package/dist/pincode-8u7yWLpQ.d.cts +29 -0
- package/dist/pincode-8u7yWLpQ.d.ts +29 -0
- package/dist/{pixelEvents-LsealscG.d.ts → pixelEvents-DqJ_CEEr.d.ts} +4 -4
- package/dist/{pixelEvents-BtEO5QAR.d.cts → pixelEvents-bahgVW4_.d.cts} +4 -4
- package/dist/{product-D9liEtl4.d.cts → product-D4kol-Z-.d.cts} +26 -2
- package/dist/{product-D9liEtl4.d.ts → product-D4kol-Z-.d.ts} +26 -2
- package/dist/store/index.cjs +20 -30
- package/dist/store/index.d.cts +21 -7
- package/dist/store/index.d.ts +21 -7
- package/dist/store/index.js +9 -26
- package/dist/{useAddressForm-DGbEn91-.d.cts → useAddressForm-fMOb5Z-a.d.ts} +6 -1
- package/dist/{useAddressForm-cO3Au33k.d.ts → useAddressForm-wleIo78M.d.cts} +6 -1
- package/dist/utils/index.cjs +60 -56
- package/dist/utils/index.d.cts +24 -9
- package/dist/utils/index.d.ts +24 -9
- package/dist/utils/index.js +4 -4
- package/dist/{wishlist-Cj0sQxiY.d.ts → wishlist-L3fM5-ie.d.ts} +1 -1
- package/dist/{wishlist-BakHvIFN.d.cts → wishlist-_0x0r1jt.d.cts} +1 -1
- package/package.json +1 -1
- package/dist/address-DwBZHzbI.d.cts +0 -19
- package/dist/address-DwBZHzbI.d.ts +0 -19
- package/dist/cart-DZq1ZEnE.d.ts +0 -153
- package/dist/cart-DwMFBmpC.d.cts +0 -153
- package/dist/chunk-34Y7Y5FU.cjs +0 -246
- package/dist/chunk-VPTN4YXD.js +0 -232
- package/dist/orders-B3G4CyhH.d.cts +0 -166
- package/dist/orders-Bl-Slh72.d.ts +0 -166
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
var chunkNE3ZHELZ_cjs = require('./chunk-NE3ZHELZ.cjs');
|
|
4
4
|
|
|
5
5
|
// src/utils/cart.ts
|
|
6
|
+
function remainingStock(product, inCart) {
|
|
7
|
+
const stock = Number(product?.stock_quantity);
|
|
8
|
+
if (product?.stock_quantity == null || Number.isNaN(stock)) return null;
|
|
9
|
+
return Math.max(stock - inCart, 0);
|
|
10
|
+
}
|
|
6
11
|
var LocalCart = {
|
|
7
12
|
get() {
|
|
8
13
|
const storeData = localStorage.getItem(chunkNE3ZHELZ_cjs.USER_CART);
|
|
@@ -11,9 +16,21 @@ var LocalCart = {
|
|
|
11
16
|
set(cart) {
|
|
12
17
|
localStorage.setItem(chunkNE3ZHELZ_cjs.USER_CART, JSON.stringify(cart));
|
|
13
18
|
},
|
|
19
|
+
/**
|
|
20
|
+
* Adds `quantity` of `product`, capped so the line never goes past the
|
|
21
|
+
* product's stock: the guest cart isn't checked against the server until
|
|
22
|
+
* checkout, so repeated adds would otherwise pile up past what's available.
|
|
23
|
+
* Returns how many units were actually added (0 when at the limit or for a
|
|
24
|
+
* pre-order); compare it with the requested quantity to tell the shopper.
|
|
25
|
+
*/
|
|
14
26
|
add(product, quantity = 1) {
|
|
15
|
-
|
|
27
|
+
if (product?.is_preorder) return 0;
|
|
28
|
+
const requested = Number(quantity) || 1;
|
|
16
29
|
const cart = this.get();
|
|
30
|
+
const inCart = Number(cart?.products_quantity?.[product.id]) || 0;
|
|
31
|
+
const remaining = remainingStock(product, inCart);
|
|
32
|
+
const qty = remaining === null ? requested : Math.min(requested, remaining);
|
|
33
|
+
if (qty <= 0) return 0;
|
|
17
34
|
if (!cart) {
|
|
18
35
|
this.set({
|
|
19
36
|
product_variants: [product],
|
|
@@ -23,31 +40,22 @@ var LocalCart = {
|
|
|
23
40
|
total_amount: Number(product.selling_price) * qty,
|
|
24
41
|
variant_discounts: {}
|
|
25
42
|
});
|
|
26
|
-
return;
|
|
43
|
+
return qty;
|
|
27
44
|
}
|
|
28
45
|
const newCart = cart.product_variants || [];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
cart.
|
|
32
|
-
...cart.products_quantity,
|
|
33
|
-
[product.id]: (Number(cart.products_quantity[product.id]) || 0) + qty
|
|
34
|
-
};
|
|
35
|
-
cart.total_quantity = Number(cart.total_quantity) + qty;
|
|
36
|
-
cart.cart_count = Number(cart.cart_count) + qty;
|
|
37
|
-
cart.total_amount = Number(cart.total_amount) + Number(product.selling_price) * qty;
|
|
38
|
-
this.set(cart);
|
|
39
|
-
return;
|
|
46
|
+
if (!newCart.some((prod) => prod.id === product.id)) {
|
|
47
|
+
newCart.push(product);
|
|
48
|
+
cart.product_variants = newCart;
|
|
40
49
|
}
|
|
41
|
-
newCart.push(product);
|
|
42
50
|
cart.products_quantity = {
|
|
43
51
|
...cart.products_quantity,
|
|
44
|
-
[product.id]:
|
|
52
|
+
[product.id]: inCart + qty
|
|
45
53
|
};
|
|
46
|
-
cart.product_variants = newCart;
|
|
47
54
|
cart.total_quantity = Number(cart.total_quantity) + qty;
|
|
48
55
|
cart.cart_count = Number(cart.cart_count) + qty;
|
|
49
56
|
cart.total_amount = Number(cart.total_amount) + Number(product.selling_price) * qty;
|
|
50
57
|
this.set(cart);
|
|
58
|
+
return qty;
|
|
51
59
|
},
|
|
52
60
|
remove(product) {
|
|
53
61
|
const cart = this.get();
|
|
@@ -25,7 +25,10 @@ var getCountries = async () => {
|
|
|
25
25
|
};
|
|
26
26
|
var getSubdivisions = async (countryId) => {
|
|
27
27
|
return chunkECHV2JSY_cjs.http_service_default.get(`utils/subdivisions/`, {
|
|
28
|
-
params: {
|
|
28
|
+
params: {
|
|
29
|
+
country_id: countryId,
|
|
30
|
+
page_size: 500
|
|
31
|
+
}
|
|
29
32
|
});
|
|
30
33
|
};
|
|
31
34
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { updateAddress, addAddress, getCountries, getSubdivisions } from './chunk-
|
|
2
|
-
import {
|
|
3
|
-
import { getAddressMeta } from './chunk-CBKJ3Y2I.js';
|
|
1
|
+
import { updateAddress, addAddress, getCountries, getSubdivisions } from './chunk-VRZRV2BR.js';
|
|
2
|
+
import { getAddressMeta } from './chunk-EWZ7TGI7.js';
|
|
4
3
|
import { addressFormInitialValues, IP_API_CACHE_KEY, addressValidationSchema, buildSubmitPayload } from './chunk-ELP23UGF.js';
|
|
4
|
+
import { getCache } from './chunk-OSM73ETC.js';
|
|
5
5
|
import { useState, useEffect, useMemo, useCallback } from 'react';
|
|
6
6
|
import { useFormik } from 'formik';
|
|
7
7
|
import { isSupportedCountry, getCountryCallingCode } from 'libphonenumber-js';
|
|
@@ -14,4 +14,11 @@ async function removeCoupon(couponCode) {
|
|
|
14
14
|
return http_service_default.delete("/coupon/use/");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
// src/api/pincode.ts
|
|
18
|
+
var getPincodeDetails = async (pincode, country) => {
|
|
19
|
+
return http_service_default.get("utils/pincode/", {
|
|
20
|
+
params: country ? { pincode, country } : { pincode }
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { applyCoupon, getAppliedCoupon, getCoupons, getPincodeDetails, removeCoupon };
|