@anker-in/shopify-react 0.1.1-beta.42 → 0.1.1-beta.43
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/hooks/index.d.mts +57 -150
- package/dist/hooks/index.d.ts +57 -150
- package/dist/hooks/index.js +63 -246
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +64 -245
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +63 -246
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -245
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +1 -1
- package/dist/provider/index.d.ts +1 -1
- package/dist/provider/index.js +35 -46
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +35 -46
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-DntkHhf8.d.mts → types-CMMWxyUF.d.mts} +2 -6
- package/dist/{types-DntkHhf8.d.ts → types-CMMWxyUF.d.ts} +2 -6
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { CartContextValue, CartProvider, CartProviderProps, LoadingState, ShopifyContext, ShopifyContextValue, ShopifyProvider, ShopifyProviderProps, useCartContext, useShopify } from './provider/index.mjs';
|
|
2
2
|
export { C as CookieAdapter, a as CookieOptions, P as PerformanceAdapter, R as RouterAdapter, U as UserContextAdapter } from './types-SKDHauqk.mjs';
|
|
3
3
|
export { BrowserPerformanceAdapter, browserCartCookieAdapter, browserCookieAdapter } from './adapters/index.mjs';
|
|
4
|
-
export { AddCartLinesInput, ApplyCartCodesInput, AutoFreeGift, AutoFreeGiftCartLineInput, AutoFreeGiftConfig, AutoFreeGiftItem, AutoFreeGiftList, AutoFreeGiftMainProduct, BuyNowInput, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, Config, CreateCartInput, DiscountLabel, FormattedGift, FunctionGiftResult, GeoLocationData, GiftProduct, GiftProductItem, GiftTier, HasPlusMemberInCartResult, ImageMedia, LocaleMapping, MAIN_PRODUCT_CODE, MEMBER_PRICE_ATTRIBUTE_KEY, MainProductInfo, NormalizedSearchResultItem, Options, OrderBasePriceType, OrderDiscountConfig, OrderDiscountResult, OrderDiscountType, PlusMemberContext, PlusMemberContextValue, PlusMemberProvider, PlusMemberProviderProps, PriceBasePriceType, PriceDiscountConfig, PriceDiscountType, RemoveCartCodesInput, RemoveCartLinesInput, RewardItem, RuleCondition, RuleType, SCRIPT_CODE_AMOUNT_KEY, SearchResult, SearchResultType, SelectedOptionsResult, ShippingMethodsContext, SiteInfo, SpendMoneyType, TieredDiscount, UpdateCartAttributesInput, UseAllBlogsOptions, UseAllCollectionsOptions, UseAllProductsOptions, UseArticleOptions, UseArticlesInBlogOptions, UseArticlesOptions, UseAutoRemovePlusMemberInCartProps, UseAvailableDeliveryCouponResult, UseBlogOptions, UseBuyNowOptions, UseCalcGiftsFromLinesOptions, UseCalcGiftsFromLinesResult, UseCollectionOptions, UseCollectionsOptions, UseExposureOptions, UseGeoLocationOptions,
|
|
5
|
-
export { a as AddToCartInput, A as AddToCartLineItem, B as BuyNowTrackConfig, g as DeliveryCustomData,
|
|
4
|
+
export { AddCartLinesInput, ApplyCartCodesInput, AutoFreeGift, AutoFreeGiftCartLineInput, AutoFreeGiftConfig, AutoFreeGiftItem, AutoFreeGiftList, AutoFreeGiftMainProduct, BuyNowInput, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, Config, CreateCartInput, DiscountLabel, FormattedGift, FunctionGiftResult, GeoLocationData, GiftProduct, GiftProductItem, GiftTier, HasPlusMemberInCartProps, HasPlusMemberInCartResult, ImageMedia, LocaleMapping, MAIN_PRODUCT_CODE, MEMBER_PRICE_ATTRIBUTE_KEY, MainProductInfo, NormalizedSearchResultItem, Options, OrderBasePriceType, OrderDiscountConfig, OrderDiscountResult, OrderDiscountType, PlusMemberContext, PlusMemberContextValue, PlusMemberProvider, PlusMemberProviderProps, PriceBasePriceType, PriceDiscountConfig, PriceDiscountType, RemoveCartCodesInput, RemoveCartLinesInput, RewardItem, RuleCondition, RuleType, SCRIPT_CODE_AMOUNT_KEY, SearchResult, SearchResultType, SelectedOptionsResult, ShippingMethodsContext, SiteInfo, SpendMoneyType, TieredDiscount, UpdateCartAttributesInput, UseAllBlogsOptions, UseAllCollectionsOptions, UseAllProductsOptions, UseArticleOptions, UseArticlesInBlogOptions, UseArticlesOptions, UseAutoRemovePlusMemberInCartProps, UseAvailableDeliveryCouponResult, UseBlogOptions, UseBuyNowOptions, UseCalcGiftsFromLinesOptions, UseCalcGiftsFromLinesResult, UseCollectionOptions, UseCollectionsOptions, UseExposureOptions, UseGeoLocationOptions, UseIntersectionOptions, UsePlusMemberVariantsOptions, UsePlusMemberVariantsResult, UsePriceOptions, UsePriceResult, UseProductOptions, UseProductsByHandlesOptions, UseScriptAutoFreeGiftResult, UseSearchOptions, UseShippingMethodsOptions, UseShippingMethodsResult, UseSiteOptions, UseUpdateCartAttributesOptions, VariantItem, VariantMedia, VideoMedia, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, hasPlusMemberInCart, normalizeAddToCartLines, preCheck, safeParse, useAddCartLines, useAddToCart, useAllBlogs, useAllCollections, useAllProducts, useApplyCartCodes, useArticle, useArticles, useArticlesInBlog, useAutoRemovePlusMemberInCart, useAvailableDeliveryCoupon, useBlog, useBuyNow, useCalcAutoFreeGift, useCalcGiftsFromLines, useCalcOrderDiscount, useCartAttributes, useCartItemQuantityLimit, useCollection, useCollections, useCreateCart, useExposure, useGeoLocation, useHasPlusMemberInCart, useIntersection, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberDeliveryCodes, usePlusMemberNeedAddToCart, usePlusMemberVariants, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethods, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdateVariantQuery, useVariant, useVariantMedia } from './hooks/index.mjs';
|
|
5
|
+
export { a as AddToCartInput, A as AddToCartLineItem, B as BuyNowTrackConfig, g as DeliveryCustomData, D as DeliveryPlusType, G as GtmParams, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, e as PlusMemberSettingsMetafields, d as PlusMemberShippingMethodConfig, c as PlusMemberShippingMethodMetafields, f as SelectedPlusMemberVariant, S as ShippingMethodMode, U as UseAddToCartOptions, h as gaTrack, k as trackAddToCartFBQ, t as trackAddToCartGA, i as trackBeginCheckoutGA, l as trackBuyNowFBQ, j as trackBuyNowGA } from './types-CMMWxyUF.mjs';
|
|
6
6
|
export * from '@anker-in/shopify-sdk';
|
|
7
7
|
import 'react';
|
|
8
8
|
import 'react/jsx-runtime';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { CartContextValue, CartProvider, CartProviderProps, LoadingState, ShopifyContext, ShopifyContextValue, ShopifyProvider, ShopifyProviderProps, useCartContext, useShopify } from './provider/index.js';
|
|
2
2
|
export { C as CookieAdapter, a as CookieOptions, P as PerformanceAdapter, R as RouterAdapter, U as UserContextAdapter } from './types-SKDHauqk.js';
|
|
3
3
|
export { BrowserPerformanceAdapter, browserCartCookieAdapter, browserCookieAdapter } from './adapters/index.js';
|
|
4
|
-
export { AddCartLinesInput, ApplyCartCodesInput, AutoFreeGift, AutoFreeGiftCartLineInput, AutoFreeGiftConfig, AutoFreeGiftItem, AutoFreeGiftList, AutoFreeGiftMainProduct, BuyNowInput, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, Config, CreateCartInput, DiscountLabel, FormattedGift, FunctionGiftResult, GeoLocationData, GiftProduct, GiftProductItem, GiftTier, HasPlusMemberInCartResult, ImageMedia, LocaleMapping, MAIN_PRODUCT_CODE, MEMBER_PRICE_ATTRIBUTE_KEY, MainProductInfo, NormalizedSearchResultItem, Options, OrderBasePriceType, OrderDiscountConfig, OrderDiscountResult, OrderDiscountType, PlusMemberContext, PlusMemberContextValue, PlusMemberProvider, PlusMemberProviderProps, PriceBasePriceType, PriceDiscountConfig, PriceDiscountType, RemoveCartCodesInput, RemoveCartLinesInput, RewardItem, RuleCondition, RuleType, SCRIPT_CODE_AMOUNT_KEY, SearchResult, SearchResultType, SelectedOptionsResult, ShippingMethodsContext, SiteInfo, SpendMoneyType, TieredDiscount, UpdateCartAttributesInput, UseAllBlogsOptions, UseAllCollectionsOptions, UseAllProductsOptions, UseArticleOptions, UseArticlesInBlogOptions, UseArticlesOptions, UseAutoRemovePlusMemberInCartProps, UseAvailableDeliveryCouponResult, UseBlogOptions, UseBuyNowOptions, UseCalcGiftsFromLinesOptions, UseCalcGiftsFromLinesResult, UseCollectionOptions, UseCollectionsOptions, UseExposureOptions, UseGeoLocationOptions,
|
|
5
|
-
export { a as AddToCartInput, A as AddToCartLineItem, B as BuyNowTrackConfig, g as DeliveryCustomData,
|
|
4
|
+
export { AddCartLinesInput, ApplyCartCodesInput, AutoFreeGift, AutoFreeGiftCartLineInput, AutoFreeGiftConfig, AutoFreeGiftItem, AutoFreeGiftList, AutoFreeGiftMainProduct, BuyNowInput, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, Config, CreateCartInput, DiscountLabel, FormattedGift, FunctionGiftResult, GeoLocationData, GiftProduct, GiftProductItem, GiftTier, HasPlusMemberInCartProps, HasPlusMemberInCartResult, ImageMedia, LocaleMapping, MAIN_PRODUCT_CODE, MEMBER_PRICE_ATTRIBUTE_KEY, MainProductInfo, NormalizedSearchResultItem, Options, OrderBasePriceType, OrderDiscountConfig, OrderDiscountResult, OrderDiscountType, PlusMemberContext, PlusMemberContextValue, PlusMemberProvider, PlusMemberProviderProps, PriceBasePriceType, PriceDiscountConfig, PriceDiscountType, RemoveCartCodesInput, RemoveCartLinesInput, RewardItem, RuleCondition, RuleType, SCRIPT_CODE_AMOUNT_KEY, SearchResult, SearchResultType, SelectedOptionsResult, ShippingMethodsContext, SiteInfo, SpendMoneyType, TieredDiscount, UpdateCartAttributesInput, UseAllBlogsOptions, UseAllCollectionsOptions, UseAllProductsOptions, UseArticleOptions, UseArticlesInBlogOptions, UseArticlesOptions, UseAutoRemovePlusMemberInCartProps, UseAvailableDeliveryCouponResult, UseBlogOptions, UseBuyNowOptions, UseCalcGiftsFromLinesOptions, UseCalcGiftsFromLinesResult, UseCollectionOptions, UseCollectionsOptions, UseExposureOptions, UseGeoLocationOptions, UseIntersectionOptions, UsePlusMemberVariantsOptions, UsePlusMemberVariantsResult, UsePriceOptions, UsePriceResult, UseProductOptions, UseProductsByHandlesOptions, UseScriptAutoFreeGiftResult, UseSearchOptions, UseShippingMethodsOptions, UseShippingMethodsResult, UseSiteOptions, UseUpdateCartAttributesOptions, VariantItem, VariantMedia, VideoMedia, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, hasPlusMemberInCart, normalizeAddToCartLines, preCheck, safeParse, useAddCartLines, useAddToCart, useAllBlogs, useAllCollections, useAllProducts, useApplyCartCodes, useArticle, useArticles, useArticlesInBlog, useAutoRemovePlusMemberInCart, useAvailableDeliveryCoupon, useBlog, useBuyNow, useCalcAutoFreeGift, useCalcGiftsFromLines, useCalcOrderDiscount, useCartAttributes, useCartItemQuantityLimit, useCollection, useCollections, useCreateCart, useExposure, useGeoLocation, useHasPlusMemberInCart, useIntersection, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberDeliveryCodes, usePlusMemberNeedAddToCart, usePlusMemberVariants, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethods, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdateVariantQuery, useVariant, useVariantMedia } from './hooks/index.js';
|
|
5
|
+
export { a as AddToCartInput, A as AddToCartLineItem, B as BuyNowTrackConfig, g as DeliveryCustomData, D as DeliveryPlusType, G as GtmParams, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, e as PlusMemberSettingsMetafields, d as PlusMemberShippingMethodConfig, c as PlusMemberShippingMethodMetafields, f as SelectedPlusMemberVariant, S as ShippingMethodMode, U as UseAddToCartOptions, h as gaTrack, k as trackAddToCartFBQ, t as trackAddToCartGA, i as trackBeginCheckoutGA, l as trackBuyNowFBQ, j as trackBuyNowGA } from './types-CMMWxyUF.js';
|
|
6
6
|
export * from '@anker-in/shopify-sdk';
|
|
7
7
|
import 'react';
|
|
8
8
|
import 'react/jsx-runtime';
|
package/dist/index.js
CHANGED
|
@@ -1573,36 +1573,46 @@ var useCalcOrderDiscount = (cart, orderDiscountConfig, customer) => {
|
|
|
1573
1573
|
isLoading: isCustomerLoading
|
|
1574
1574
|
};
|
|
1575
1575
|
};
|
|
1576
|
-
function
|
|
1576
|
+
function hasPlusMemberInCart({
|
|
1577
1577
|
memberSetting,
|
|
1578
1578
|
cart
|
|
1579
1579
|
}) {
|
|
1580
1580
|
const { plus_monthly_product, plus_annual_product } = memberSetting || {};
|
|
1581
|
-
|
|
1582
|
-
if (!cart?.lineItems) {
|
|
1583
|
-
return {
|
|
1584
|
-
hasPlusMember: false,
|
|
1585
|
-
hasMonthlyPlus: false,
|
|
1586
|
-
hasAnnualPlus: false
|
|
1587
|
-
};
|
|
1588
|
-
}
|
|
1589
|
-
const monthlyPlusItem = cart.lineItems.find(
|
|
1590
|
-
(item) => item.product?.handle === plus_monthly_product?.handle && item.variant?.sku === plus_monthly_product?.sku
|
|
1591
|
-
);
|
|
1592
|
-
const annualPlusItem = cart.lineItems.find(
|
|
1593
|
-
(item) => item.product?.handle === plus_annual_product?.handle && item.variant?.sku === plus_annual_product?.sku
|
|
1594
|
-
);
|
|
1595
|
-
const hasMonthlyPlus = !!monthlyPlusItem;
|
|
1596
|
-
const hasAnnualPlus = !!annualPlusItem;
|
|
1597
|
-
const hasPlusMember = hasMonthlyPlus || hasAnnualPlus;
|
|
1581
|
+
if (!cart?.lineItems) {
|
|
1598
1582
|
return {
|
|
1599
|
-
hasPlusMember,
|
|
1600
|
-
hasMonthlyPlus,
|
|
1601
|
-
hasAnnualPlus
|
|
1602
|
-
monthlyPlusItem,
|
|
1603
|
-
annualPlusItem
|
|
1583
|
+
hasPlusMember: false,
|
|
1584
|
+
hasMonthlyPlus: false,
|
|
1585
|
+
hasAnnualPlus: false
|
|
1604
1586
|
};
|
|
1605
|
-
}
|
|
1587
|
+
}
|
|
1588
|
+
const monthlyPlusItem = cart.lineItems.find(
|
|
1589
|
+
(item) => item.product?.handle === plus_monthly_product?.handle && item.variant?.sku === plus_monthly_product?.sku
|
|
1590
|
+
);
|
|
1591
|
+
const annualPlusItem = cart.lineItems.find(
|
|
1592
|
+
(item) => item.product?.handle === plus_annual_product?.handle && item.variant?.sku === plus_annual_product?.sku
|
|
1593
|
+
);
|
|
1594
|
+
const hasMonthlyPlus = !!monthlyPlusItem;
|
|
1595
|
+
const hasAnnualPlus = !!annualPlusItem;
|
|
1596
|
+
const hasPlusMember = hasMonthlyPlus || hasAnnualPlus;
|
|
1597
|
+
return {
|
|
1598
|
+
hasPlusMember,
|
|
1599
|
+
hasMonthlyPlus,
|
|
1600
|
+
hasAnnualPlus,
|
|
1601
|
+
monthlyPlusItem,
|
|
1602
|
+
annualPlusItem
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
function useHasPlusMemberInCart({
|
|
1606
|
+
memberSetting,
|
|
1607
|
+
cart
|
|
1608
|
+
}) {
|
|
1609
|
+
return react.useMemo(
|
|
1610
|
+
() => hasPlusMemberInCart({
|
|
1611
|
+
memberSetting,
|
|
1612
|
+
cart
|
|
1613
|
+
}),
|
|
1614
|
+
[memberSetting, cart]
|
|
1615
|
+
);
|
|
1606
1616
|
}
|
|
1607
1617
|
var getReferralAttributes = () => {
|
|
1608
1618
|
const inviteCode = shopifySdk.getLocalStorage("inviteCode") || Cookies5__default.default.get("inviteCode");
|
|
@@ -2581,28 +2591,13 @@ var ShippingMethodMode = /* @__PURE__ */ ((ShippingMethodMode2) => {
|
|
|
2581
2591
|
return ShippingMethodMode2;
|
|
2582
2592
|
})(ShippingMethodMode || {});
|
|
2583
2593
|
var createInitialValue = () => ({
|
|
2584
|
-
zipCode: "",
|
|
2585
2594
|
plusMemberMetafields: {},
|
|
2586
|
-
setZipCode: () => {
|
|
2587
|
-
},
|
|
2588
|
-
allowNextDayDelivery: false,
|
|
2589
|
-
setAllowNextDayDelivery: () => {
|
|
2590
|
-
},
|
|
2591
|
-
allowThirdDayDelivery: false,
|
|
2592
|
-
setAllowThirdDayDelivery: () => {
|
|
2593
|
-
},
|
|
2594
2595
|
selectedPlusMemberMode: "free",
|
|
2595
2596
|
setSelectedPlusMemberMode: () => {
|
|
2596
2597
|
},
|
|
2597
|
-
showAreaCheckModal: false,
|
|
2598
|
-
setShowAreaCheckModal: () => {
|
|
2599
|
-
},
|
|
2600
2598
|
selectedShippingMethod: void 0,
|
|
2601
2599
|
setSelectedShippingMethod: () => {
|
|
2602
2600
|
},
|
|
2603
|
-
showTip: false,
|
|
2604
|
-
setShowTip: () => {
|
|
2605
|
-
},
|
|
2606
2601
|
showMoreShippingMethod: false,
|
|
2607
2602
|
setShowMoreShippingMethod: () => {
|
|
2608
2603
|
},
|
|
@@ -2618,16 +2613,10 @@ var createInitialValue = () => ({
|
|
|
2618
2613
|
isLoadingCoupon: false
|
|
2619
2614
|
},
|
|
2620
2615
|
selectedPlusMemberVariant: void 0,
|
|
2621
|
-
monthlyVariant: void 0,
|
|
2622
|
-
annualVariant: void 0,
|
|
2623
2616
|
showPlusMemberBenefit: false,
|
|
2624
2617
|
setShowPlusMemberBenefit: () => {
|
|
2625
2618
|
},
|
|
2626
|
-
|
|
2627
|
-
setDeleteMarginBottom: () => {
|
|
2628
|
-
},
|
|
2629
|
-
profile: void 0,
|
|
2630
|
-
locale: void 0
|
|
2619
|
+
profile: void 0
|
|
2631
2620
|
});
|
|
2632
2621
|
var PlusMemberContext = react.createContext(createInitialValue());
|
|
2633
2622
|
function usePlusMemberContext() {
|
|
@@ -2687,9 +2676,9 @@ var useAvailableDeliveryCoupon = ({
|
|
|
2687
2676
|
|
|
2688
2677
|
// src/hooks/member/plus/use-shipping-methods.ts
|
|
2689
2678
|
function useShippingMethods(options) {
|
|
2690
|
-
const { variant, plusMemberMetafields, selectedPlusMemberMode,
|
|
2679
|
+
const { variant, plusMemberMetafields, selectedPlusMemberMode, profile } = options;
|
|
2680
|
+
const isPlus = profile?.isPlus || false;
|
|
2691
2681
|
const { nddCoupon, tddCoupon, isLoading } = useAvailableDeliveryCoupon({ profile });
|
|
2692
|
-
console.log("nddCoupon", nddCoupon);
|
|
2693
2682
|
const { plus_shipping, shippingMethod } = plusMemberMetafields || {};
|
|
2694
2683
|
const nddOverweight = react.useMemo(() => {
|
|
2695
2684
|
return (variant?.weight || 0) > (shippingMethod?.overWeight_ndd || Infinity);
|
|
@@ -2816,69 +2805,6 @@ function useShippingMethods(options) {
|
|
|
2816
2805
|
isLoadingCoupon: isLoading
|
|
2817
2806
|
};
|
|
2818
2807
|
}
|
|
2819
|
-
function useShippingMethodAvailableCheck() {
|
|
2820
|
-
const {
|
|
2821
|
-
zipCode,
|
|
2822
|
-
allowNextDayDelivery,
|
|
2823
|
-
allowThirdDayDelivery,
|
|
2824
|
-
selectedShippingMethod,
|
|
2825
|
-
setSelectedShippingMethod,
|
|
2826
|
-
setShowTip,
|
|
2827
|
-
shippingMethodsContext
|
|
2828
|
-
} = usePlusMemberContext();
|
|
2829
|
-
react.useEffect(() => {
|
|
2830
|
-
const freeShippingMethod = shippingMethodsContext.freeShippingMethods[0];
|
|
2831
|
-
const standardShippingMethod = shippingMethodsContext.freeShippingMethods?.find(
|
|
2832
|
-
(item) => item.__mode === "free" /* FREE */
|
|
2833
|
-
);
|
|
2834
|
-
const freeTDD = shippingMethodsContext.freeShippingMethods.find(
|
|
2835
|
-
(item) => item.__mode === "tdd" /* TDD */
|
|
2836
|
-
);
|
|
2837
|
-
const paymentTDD = shippingMethodsContext.paymentShippingMethods.find(
|
|
2838
|
-
(item) => item.__mode === "tdd" /* TDD */
|
|
2839
|
-
);
|
|
2840
|
-
if (zipCode) {
|
|
2841
|
-
console.log(
|
|
2842
|
-
"allowNextDayDelivery, allowThirdDayDelivery:",
|
|
2843
|
-
allowNextDayDelivery,
|
|
2844
|
-
allowThirdDayDelivery
|
|
2845
|
-
);
|
|
2846
|
-
if (!allowNextDayDelivery && !allowThirdDayDelivery) {
|
|
2847
|
-
setShowTip(true);
|
|
2848
|
-
setSelectedShippingMethod(standardShippingMethod);
|
|
2849
|
-
} else {
|
|
2850
|
-
if (selectedShippingMethod?.__mode === "ndd" /* NDD */ && !allowNextDayDelivery) {
|
|
2851
|
-
setShowTip(true);
|
|
2852
|
-
if (allowThirdDayDelivery) {
|
|
2853
|
-
if (selectedShippingMethod.useCoupon) {
|
|
2854
|
-
const method = freeTDD || freeShippingMethod;
|
|
2855
|
-
if (method) setSelectedShippingMethod(method);
|
|
2856
|
-
} else {
|
|
2857
|
-
const method = paymentTDD || freeShippingMethod;
|
|
2858
|
-
if (method) setSelectedShippingMethod(method);
|
|
2859
|
-
}
|
|
2860
|
-
} else {
|
|
2861
|
-
if (freeShippingMethod) setSelectedShippingMethod(freeShippingMethod);
|
|
2862
|
-
}
|
|
2863
|
-
} else if (
|
|
2864
|
-
// TDD 无法使用
|
|
2865
|
-
selectedShippingMethod?.__mode === "tdd" /* TDD */ && !allowThirdDayDelivery
|
|
2866
|
-
) {
|
|
2867
|
-
setShowTip(true);
|
|
2868
|
-
if (freeShippingMethod) setSelectedShippingMethod(freeShippingMethod);
|
|
2869
|
-
}
|
|
2870
|
-
}
|
|
2871
|
-
}
|
|
2872
|
-
}, [
|
|
2873
|
-
allowNextDayDelivery,
|
|
2874
|
-
allowThirdDayDelivery,
|
|
2875
|
-
zipCode,
|
|
2876
|
-
shippingMethodsContext,
|
|
2877
|
-
selectedShippingMethod,
|
|
2878
|
-
setSelectedShippingMethod,
|
|
2879
|
-
setShowTip
|
|
2880
|
-
]);
|
|
2881
|
-
}
|
|
2882
2808
|
var useReplaceCartPlusMember = () => {
|
|
2883
2809
|
const { plusMemberMetafields, selectedPlusMemberMode } = usePlusMemberContext();
|
|
2884
2810
|
const { trigger: removeCartLines2 } = useRemoveCartLines();
|
|
@@ -2910,129 +2836,45 @@ var useReplaceCartPlusMember = () => {
|
|
|
2910
2836
|
]);
|
|
2911
2837
|
return handler;
|
|
2912
2838
|
};
|
|
2913
|
-
var usePlusMemberDeliveryCodes = ({
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
return react.useMemo(
|
|
2917
|
-
() => deliveryData?.deliveryCustomData?.discount_code,
|
|
2918
|
-
[deliveryData]
|
|
2919
|
-
);
|
|
2920
|
-
};
|
|
2921
|
-
function useUpdateCartDeliveryOptions(mutate, metafieldIdentifiers, options) {
|
|
2922
|
-
const { client, locale, cartCookieAdapter } = useShopify();
|
|
2923
|
-
const updateDeliveryOptions = react.useCallback(
|
|
2924
|
-
async (_key, { arg }) => {
|
|
2925
|
-
const updatedCart = await shopifySdk.updateCartDeliveryOptions(client, {
|
|
2926
|
-
...arg,
|
|
2927
|
-
metafieldIdentifiers,
|
|
2928
|
-
cookieAdapter: cartCookieAdapter
|
|
2929
|
-
});
|
|
2930
|
-
console.log("useUpdateCartDeliveryOptions updatedCart", updatedCart);
|
|
2931
|
-
if (updatedCart) {
|
|
2932
|
-
mutate(updatedCart);
|
|
2933
|
-
}
|
|
2934
|
-
return updatedCart;
|
|
2935
|
-
},
|
|
2936
|
-
[client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
|
|
2937
|
-
);
|
|
2938
|
-
return useSWRMutation__default.default("update-cart-delivery-options", updateDeliveryOptions, options);
|
|
2939
|
-
}
|
|
2940
|
-
|
|
2941
|
-
// src/hooks/member/plus/use-update-plus-member-delivery-options.ts
|
|
2942
|
-
var useUpdatePlusMemberDeliveryOptions = ({
|
|
2943
|
-
options
|
|
2944
|
-
} = {}) => {
|
|
2945
|
-
const { cart: cartContextData, mutateCart, metafieldIdentifiers } = useCartContext();
|
|
2946
|
-
const { trigger: updateCartDeliveryOptions2 } = useUpdateCartDeliveryOptions(
|
|
2947
|
-
mutateCart,
|
|
2948
|
-
metafieldIdentifiers
|
|
2949
|
-
);
|
|
2950
|
-
const handler = react.useCallback(
|
|
2951
|
-
async (_, { arg }) => {
|
|
2952
|
-
const currentCart = arg?.cart || cartContextData;
|
|
2953
|
-
const { deliveryData } = arg;
|
|
2954
|
-
const firstDeliveryGroup = currentCart?.deliveryGroups?.[0];
|
|
2955
|
-
const deliveryGroupId = firstDeliveryGroup?.id;
|
|
2956
|
-
const selectedOptionCode = deliveryData?.deliveryCustomData?.selected_delivery_option?.code;
|
|
2957
|
-
if (!deliveryGroupId || !selectedOptionCode || selectedOptionCode === firstDeliveryGroup?.selectedDeliveryOption?.code) {
|
|
2958
|
-
return null;
|
|
2959
|
-
}
|
|
2960
|
-
const deliveryGroup = currentCart?.deliveryGroups?.find(
|
|
2961
|
-
(group) => group?.id === deliveryGroupId
|
|
2962
|
-
);
|
|
2963
|
-
const matchedOption = deliveryGroup?.deliveryOptions?.find(
|
|
2964
|
-
(option) => option?.code === selectedOptionCode
|
|
2965
|
-
);
|
|
2966
|
-
if (!matchedOption?.handle) {
|
|
2967
|
-
return null;
|
|
2968
|
-
}
|
|
2969
|
-
const deliveryOptions = [
|
|
2970
|
-
{
|
|
2971
|
-
deliveryGroupId,
|
|
2972
|
-
deliveryOptionHandle: matchedOption.handle
|
|
2973
|
-
}
|
|
2974
|
-
];
|
|
2975
|
-
const updatedCart = await updateCartDeliveryOptions2({
|
|
2976
|
-
selectedDeliveryOptions: deliveryOptions,
|
|
2977
|
-
cartId: currentCart?.id
|
|
2978
|
-
});
|
|
2979
|
-
if (updatedCart && mutateCart) {
|
|
2980
|
-
mutateCart(updatedCart);
|
|
2981
|
-
}
|
|
2982
|
-
return updatedCart;
|
|
2983
|
-
},
|
|
2984
|
-
[cartContextData, updateCartDeliveryOptions2, mutateCart]
|
|
2985
|
-
);
|
|
2986
|
-
return useSWRMutation__default.default("update-cart-delivery-options", handler, options);
|
|
2987
|
-
};
|
|
2988
|
-
var usePlusMemberItemCustomAttributes = ({
|
|
2989
|
-
deliveryData
|
|
2990
|
-
}) => {
|
|
2991
|
-
const { deliveryCustomData } = deliveryData || {};
|
|
2992
|
-
return react.useMemo(() => {
|
|
2993
|
-
const itemCustomAttributes = [];
|
|
2994
|
-
if (deliveryCustomData?.is_presale) {
|
|
2995
|
-
itemCustomAttributes.push({
|
|
2996
|
-
key: "_is_presale",
|
|
2997
|
-
value: "true"
|
|
2998
|
-
});
|
|
2999
|
-
}
|
|
3000
|
-
return itemCustomAttributes;
|
|
3001
|
-
}, [deliveryCustomData]);
|
|
2839
|
+
var usePlusMemberDeliveryCodes = () => {
|
|
2840
|
+
const { selectedShippingMethod } = usePlusMemberContext();
|
|
2841
|
+
return react.useMemo(() => [selectedShippingMethod?.coupon], [selectedShippingMethod?.coupon]);
|
|
3002
2842
|
};
|
|
3003
2843
|
var usePlusMemberCheckoutCustomAttributes = ({
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
variant,
|
|
3007
|
-
isShowShippingBenefits
|
|
2844
|
+
disableShipping = false,
|
|
2845
|
+
isPresaleContains = false
|
|
3008
2846
|
}) => {
|
|
3009
|
-
const {
|
|
3010
|
-
const { profile } = usePlusMemberContext();
|
|
2847
|
+
const { profile, selectedShippingMethod, selectedPlusMemberMode } = usePlusMemberContext();
|
|
3011
2848
|
return react.useMemo(() => {
|
|
3012
2849
|
const checkoutCustomAttributes = [
|
|
3013
|
-
// _last_url: 付费会员结算完成之后 checkout 有一个继续购买的按钮, 用于跳转到继续购买的页面
|
|
3014
2850
|
{
|
|
3015
2851
|
key: "_last_url",
|
|
3016
2852
|
value: typeof window !== "undefined" ? window.location.origin + window.location.pathname : ""
|
|
3017
2853
|
}
|
|
3018
2854
|
];
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
2855
|
+
checkoutCustomAttributes.push({
|
|
2856
|
+
key: "_checkout_delivery_custom",
|
|
2857
|
+
value: JSON.stringify({
|
|
2858
|
+
allow_nextday_delivery: true,
|
|
2859
|
+
allow_thirdday_delivery: true,
|
|
2860
|
+
selected_delivery_option: {
|
|
2861
|
+
code: selectedShippingMethod?.__code,
|
|
2862
|
+
mode: selectedShippingMethod?.__mode
|
|
2863
|
+
},
|
|
2864
|
+
is_presale: isPresaleContains,
|
|
2865
|
+
discount_code: selectedShippingMethod?.coupon ? [selectedShippingMethod.coupon] : [],
|
|
2866
|
+
plus_type: profile?.isPlus ? "free" /* FREE */ : selectedPlusMemberMode,
|
|
2867
|
+
is_prime: profile?.isPlus
|
|
2868
|
+
})
|
|
2869
|
+
});
|
|
2870
|
+
if (disableShipping) {
|
|
3029
2871
|
checkoutCustomAttributes.push({
|
|
3030
2872
|
key: "_hide_shipping",
|
|
3031
2873
|
value: "true"
|
|
3032
2874
|
});
|
|
3033
2875
|
}
|
|
3034
2876
|
return checkoutCustomAttributes;
|
|
3035
|
-
}, [
|
|
2877
|
+
}, [profile, selectedShippingMethod, selectedPlusMemberMode, isPresaleContains]);
|
|
3036
2878
|
};
|
|
3037
2879
|
function useAutoRemovePlusMemberInCart({
|
|
3038
2880
|
cart,
|
|
@@ -3099,25 +2941,17 @@ var PlusMemberProvider = ({
|
|
|
3099
2941
|
profile,
|
|
3100
2942
|
children
|
|
3101
2943
|
}) => {
|
|
3102
|
-
const { locale } = useShopify();
|
|
3103
|
-
const [zipCode, setZipCode] = react.useState("");
|
|
3104
|
-
const [showTip, setShowTip] = react.useState(false);
|
|
3105
2944
|
const [selectedPlusMemberMode, setSelectedPlusMemberMode] = react.useState(
|
|
3106
2945
|
initialSelectedPlusMemberMode
|
|
3107
2946
|
);
|
|
3108
2947
|
const [selectedShippingMethod, setSelectedShippingMethod] = react.useState();
|
|
3109
|
-
const [allowNextDayDelivery, setAllowNextDayDelivery] = react.useState(false);
|
|
3110
|
-
const [allowThirdDayDelivery, setAllowThirdDayDelivery] = react.useState(false);
|
|
3111
|
-
const [showAreaCheckModal, setShowAreaCheckModal] = react.useState(false);
|
|
3112
2948
|
const [showMoreShippingMethod, setShowMoreShippingMethod] = react.useState(false);
|
|
3113
2949
|
const [showPlusMemberBenefit, setShowPlusMemberBenefit] = react.useState(false);
|
|
3114
|
-
const [deleteMarginBottom, setDeleteMarginBottom] = react.useState(false);
|
|
3115
2950
|
const shippingMethodsContext = useShippingMethods({
|
|
3116
2951
|
variant,
|
|
3117
2952
|
plusMemberMetafields: memberSetting,
|
|
3118
2953
|
selectedPlusMemberMode,
|
|
3119
|
-
profile
|
|
3120
|
-
isPlus: profile?.isPlus || false
|
|
2954
|
+
profile
|
|
3121
2955
|
});
|
|
3122
2956
|
const { monthlyVariant, annualVariant } = usePlusMemberVariants({
|
|
3123
2957
|
memberSetting
|
|
@@ -3133,34 +2967,19 @@ var PlusMemberProvider = ({
|
|
|
3133
2967
|
{
|
|
3134
2968
|
value: {
|
|
3135
2969
|
variant,
|
|
3136
|
-
zipCode,
|
|
3137
|
-
setZipCode,
|
|
3138
|
-
allowNextDayDelivery,
|
|
3139
|
-
setAllowNextDayDelivery,
|
|
3140
|
-
allowThirdDayDelivery,
|
|
3141
|
-
setAllowThirdDayDelivery,
|
|
3142
2970
|
plusMemberMetafields: memberSetting,
|
|
3143
2971
|
selectedPlusMemberMode,
|
|
3144
2972
|
setSelectedPlusMemberMode,
|
|
3145
|
-
showAreaCheckModal,
|
|
3146
|
-
setShowAreaCheckModal,
|
|
3147
2973
|
selectedShippingMethod,
|
|
3148
2974
|
setSelectedShippingMethod,
|
|
3149
2975
|
shippingMethodsContext,
|
|
3150
|
-
showTip,
|
|
3151
|
-
setShowTip,
|
|
3152
2976
|
showMoreShippingMethod,
|
|
3153
2977
|
setShowMoreShippingMethod,
|
|
3154
2978
|
selectedPlusMemberVariant,
|
|
3155
|
-
monthlyVariant,
|
|
3156
|
-
annualVariant,
|
|
3157
2979
|
product,
|
|
3158
2980
|
showPlusMemberBenefit,
|
|
3159
2981
|
setShowPlusMemberBenefit,
|
|
3160
|
-
|
|
3161
|
-
setDeleteMarginBottom,
|
|
3162
|
-
profile,
|
|
3163
|
-
locale
|
|
2982
|
+
profile
|
|
3164
2983
|
},
|
|
3165
2984
|
children
|
|
3166
2985
|
}
|
|
@@ -3612,6 +3431,7 @@ exports.getDiscountEnvAttributeValue = getDiscountEnvAttributeValue;
|
|
|
3612
3431
|
exports.getMatchedMainProductSubTotal = getMatchedMainProductSubTotal;
|
|
3613
3432
|
exports.getQuery = getQuery;
|
|
3614
3433
|
exports.getReferralAttributes = getReferralAttributes;
|
|
3434
|
+
exports.hasPlusMemberInCart = hasPlusMemberInCart;
|
|
3615
3435
|
exports.normalizeAddToCartLines = normalizeAddToCartLines;
|
|
3616
3436
|
exports.preCheck = preCheck;
|
|
3617
3437
|
exports.safeParse = safeParse;
|
|
@@ -3649,7 +3469,6 @@ exports.useIntersection = useIntersection;
|
|
|
3649
3469
|
exports.usePlusMemberCheckoutCustomAttributes = usePlusMemberCheckoutCustomAttributes;
|
|
3650
3470
|
exports.usePlusMemberContext = usePlusMemberContext;
|
|
3651
3471
|
exports.usePlusMemberDeliveryCodes = usePlusMemberDeliveryCodes;
|
|
3652
|
-
exports.usePlusMemberItemCustomAttributes = usePlusMemberItemCustomAttributes;
|
|
3653
3472
|
exports.usePlusMemberNeedAddToCart = usePlusMemberNeedAddToCart;
|
|
3654
3473
|
exports.usePlusMemberVariants = usePlusMemberVariants;
|
|
3655
3474
|
exports.usePrice = usePrice;
|
|
@@ -3662,14 +3481,12 @@ exports.useReplaceCartPlusMember = useReplaceCartPlusMember;
|
|
|
3662
3481
|
exports.useScriptAutoFreeGift = useScriptAutoFreeGift;
|
|
3663
3482
|
exports.useSearch = useSearch;
|
|
3664
3483
|
exports.useSelectedOptions = useSelectedOptions;
|
|
3665
|
-
exports.useShippingMethodAvailableCheck = useShippingMethodAvailableCheck;
|
|
3666
3484
|
exports.useShippingMethods = useShippingMethods;
|
|
3667
3485
|
exports.useShopify = useShopify;
|
|
3668
3486
|
exports.useSite = useSite;
|
|
3669
3487
|
exports.useUpdateCartAttributes = useUpdateCartAttributes;
|
|
3670
3488
|
exports.useUpdateCartLines = useUpdateCartLines;
|
|
3671
3489
|
exports.useUpdateLineCodeAmountAttributes = useUpdateLineCodeAmountAttributes;
|
|
3672
|
-
exports.useUpdatePlusMemberDeliveryOptions = useUpdatePlusMemberDeliveryOptions;
|
|
3673
3490
|
exports.useUpdateVariantQuery = useUpdateVariantQuery;
|
|
3674
3491
|
exports.useVariant = useVariant;
|
|
3675
3492
|
exports.useVariantMedia = useVariantMedia;
|