@anker-in/shopify-react 0.1.1-beta.19 → 0.1.1-beta.20
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/adapters/index.d.mts +2 -2
- package/dist/adapters/index.d.ts +2 -2
- package/dist/hooks/index.d.mts +12 -14
- package/dist/hooks/index.d.ts +12 -14
- package/dist/hooks/index.js +5 -19
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +5 -17
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +18 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -18
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +7 -9
- package/dist/provider/index.d.ts +7 -9
- package/dist/provider/index.js +12 -17
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +11 -16
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-DX-2ABDs.d.mts → types-C1So3siD.d.mts} +2 -16
- package/dist/{types-DX-2ABDs.d.ts → types-C1So3siD.d.ts} +2 -16
- package/dist/{types-BLMoxbOk.d.mts → types-Dt0DUG00.d.mts} +1 -9
- package/dist/{types-BLMoxbOk.d.ts → types-Dt0DUG00.d.ts} +1 -9
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, useMemo, useContext, useRef, useState, useEffect, useCallback } from 'react';
|
|
2
|
-
import { createShopifyClient, getProductsByHandles, createCart, updateCartCodes, addCartLines, updateCartLines, removeCartLines, updateCartAttributes, getProduct, getAllProducts, getCollection, getAllCollections, getCollections, getBlog, getAllBlogs, getArticle, getArticles, getArticlesInBlog,
|
|
3
|
-
export
|
|
2
|
+
import { createShopifyClient, atobID, btoaID, getProductsByHandles, createCart, updateCartCodes, addCartLines, updateCartLines, removeCartLines, updateCartAttributes, getLocalStorage, getProduct, getAllProducts, getCollection, getAllCollections, getCollections, getBlog, getAllBlogs, getArticle, getArticles, getArticlesInBlog, getCart, setLocalStorage, updateCartDeliveryOptions } from '@anker-in/shopify-sdk';
|
|
3
|
+
export * from '@anker-in/shopify-sdk';
|
|
4
4
|
import Cookies5 from 'js-cookie';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
import Decimal2 from 'decimal.js';
|
|
@@ -226,16 +226,6 @@ var getQuery = () => {
|
|
|
226
226
|
}
|
|
227
227
|
return theRequest;
|
|
228
228
|
};
|
|
229
|
-
function atobID(id) {
|
|
230
|
-
if (id && typeof id === "string" && id.includes("/")) {
|
|
231
|
-
return id.split("/").pop()?.split("?")?.shift();
|
|
232
|
-
} else {
|
|
233
|
-
return id;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
function btoaID(id, type = "ProductVariant") {
|
|
237
|
-
return `gid://shopify/${type}/${id}`;
|
|
238
|
-
}
|
|
239
229
|
var getMatchedMainProductSubTotal = (cartData, variant_list, main_product) => {
|
|
240
230
|
const isAllStoreVariant = main_product?.all_store_variant ?? false;
|
|
241
231
|
const matchedList = cartData?.lineItems?.filter((line) => {
|
|
@@ -1380,12 +1370,10 @@ function useHasPlusMemberInCart({
|
|
|
1380
1370
|
};
|
|
1381
1371
|
}, [cart?.lineItems, plus_monthly_product, plus_annual_product]);
|
|
1382
1372
|
}
|
|
1383
|
-
|
|
1384
|
-
// src/hooks/cart/feature/use-cart-attributes.ts
|
|
1385
1373
|
var getReferralAttributes = () => {
|
|
1386
|
-
const inviteCode = Cookies5.get("invite_code");
|
|
1387
|
-
const playModeId = Cookies5.get("playModeId");
|
|
1388
|
-
const popup = Cookies5.get("_popup");
|
|
1374
|
+
const inviteCode = getLocalStorage("invite_code") || Cookies5.get("invite_code");
|
|
1375
|
+
const playModeId = getLocalStorage("playModeId") || Cookies5.get("playModeId");
|
|
1376
|
+
const popup = getLocalStorage("_popup") || Cookies5.get("_popup");
|
|
1389
1377
|
if (inviteCode && playModeId) {
|
|
1390
1378
|
return popup ? [
|
|
1391
1379
|
{ key: "_invite_code", value: inviteCode ? inviteCode : "" },
|
|
@@ -3281,8 +3269,14 @@ function CartProvider({
|
|
|
3281
3269
|
);
|
|
3282
3270
|
return result;
|
|
3283
3271
|
}, [cart?.lineItems, scriptAutoFreeGift, functionAutoFreeGift]);
|
|
3272
|
+
const totalQuantity = useMemo(() => {
|
|
3273
|
+
const cartLinesCount = cart?.lineItems.reduce((acc, item) => acc + item.quantity, 0) || 0;
|
|
3274
|
+
const giftLinesCount = giftNeedAddToCartLines?.reduce((acc, item) => acc + (item.quantity || 1), 0) || 0;
|
|
3275
|
+
return cartLinesCount + giftLinesCount;
|
|
3276
|
+
}, [cart?.lineItems, giftNeedAddToCartLines]);
|
|
3284
3277
|
const value = useMemo(
|
|
3285
3278
|
() => ({
|
|
3279
|
+
totalQuantity,
|
|
3286
3280
|
cart,
|
|
3287
3281
|
isCartLoading,
|
|
3288
3282
|
triggerFetch: fetchCart,
|
|
@@ -3310,6 +3304,7 @@ function CartProvider({
|
|
|
3310
3304
|
}),
|
|
3311
3305
|
[
|
|
3312
3306
|
cart,
|
|
3307
|
+
totalQuantity,
|
|
3313
3308
|
isCartLoading,
|
|
3314
3309
|
fetchCart,
|
|
3315
3310
|
mutateCart,
|
|
@@ -3342,6 +3337,6 @@ function useCartContext() {
|
|
|
3342
3337
|
return context;
|
|
3343
3338
|
}
|
|
3344
3339
|
|
|
3345
|
-
export { BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, CartProvider, DeliveryPlusType, MAIN_PRODUCT_CODE, OrderBasePriceType, OrderDiscountType, PLUS_MEMBER_TYPE, PlusMemberContext, PlusMemberMode, PlusMemberProvider, PriceBasePriceType, PriceDiscountType, RuleType, SCRIPT_CODE_AMOUNT_KEY, ShippingMethodMode, ShopifyContext, ShopifyProvider, SpendMoneyType,
|
|
3340
|
+
export { BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, CartProvider, DeliveryPlusType, MAIN_PRODUCT_CODE, OrderBasePriceType, OrderDiscountType, PLUS_MEMBER_TYPE, PlusMemberContext, PlusMemberMode, PlusMemberProvider, PriceBasePriceType, PriceDiscountType, RuleType, SCRIPT_CODE_AMOUNT_KEY, ShippingMethodMode, ShopifyContext, ShopifyProvider, SpendMoneyType, browserCartCookieAdapter, browserCookieAdapter, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, gaTrack, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, normalizeAddToCartLines, preCheck, safeParse, trackAddToCartFBQ, trackAddToCartGA, trackBeginCheckoutGA, trackBuyNowFBQ, trackBuyNowGA, useAddCartLines, useAddPlusMemberProductsToCart, useAddToCart, useAllBlogs, useAllCollections, useAllProducts, useApplyCartCodes, useArticle, useArticles, useArticlesInBlog, useAutoRemovePlusMemberInCart, useBlog, useBuyNow, useCalcAutoFreeGift, useCalcGiftsFromLines, useCalcOrderDiscount, useCartAttributes, useCartContext, useCartItemQuantityLimit, useCollection, useCollections, useCreateCart, useExposure, useGeoLocation, useHasPlusMemberInCart, useIntersection, usePlusAnnualProductVariant, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberDeliveryCodes, usePlusMemberItemCustomAttributes, usePlusMonthlyProductVariant, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethodAvailableCheck, useShippingMethods, useShopify, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdatePlusMemberDeliveryOptions, useUpdateVariantQuery, useVariant, useVariantMedia };
|
|
3346
3341
|
//# sourceMappingURL=index.mjs.map
|
|
3347
3342
|
//# sourceMappingURL=index.mjs.map
|