@anker-in/shopify-react 0.1.1-beta.35 → 0.1.1-beta.36
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 +16 -13
- package/dist/hooks/index.d.ts +16 -13
- package/dist/hooks/index.js +119 -81
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +119 -82
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +119 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -82
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.js +65 -39
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +65 -39
- package/dist/provider/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/hooks/index.d.mts
CHANGED
|
@@ -719,8 +719,6 @@ declare function usePlusAnnualProductVariant<TVariant = any>(): TVariant | undef
|
|
|
719
719
|
interface UseShippingMethodsOptions<TVariant = any> {
|
|
720
720
|
/** Product variant with weight information */
|
|
721
721
|
variant: TVariant;
|
|
722
|
-
/** Zip code for delivery */
|
|
723
|
-
zipCode: string;
|
|
724
722
|
/** Whether next day delivery is allowed */
|
|
725
723
|
allowNextDayDelivery: boolean;
|
|
726
724
|
/** Whether third day delivery is allowed */
|
|
@@ -731,16 +729,16 @@ interface UseShippingMethodsOptions<TVariant = any> {
|
|
|
731
729
|
selectedPlusMemberMode: DeliveryPlusType;
|
|
732
730
|
/** Whether user is a plus member */
|
|
733
731
|
isPlus?: boolean;
|
|
734
|
-
|
|
735
|
-
nddCoupon?: string;
|
|
736
|
-
/** Available TDD coupon code */
|
|
737
|
-
tddCoupon?: string;
|
|
732
|
+
profile?: any;
|
|
738
733
|
}
|
|
739
734
|
interface UseShippingMethodsResult {
|
|
740
735
|
freeShippingMethods: PlusMemberShippingMethodConfig[];
|
|
741
736
|
paymentShippingMethods: PlusMemberShippingMethodConfig[];
|
|
742
737
|
nddOverweight: boolean;
|
|
743
738
|
tddOverweight: boolean;
|
|
739
|
+
nddCoupon?: string;
|
|
740
|
+
tddCoupon?: string;
|
|
741
|
+
isLoadingCoupon: boolean;
|
|
744
742
|
}
|
|
745
743
|
/**
|
|
746
744
|
* Calculate available shipping methods based on product weight, member status, and available coupons
|
|
@@ -752,14 +750,11 @@ interface UseShippingMethodsResult {
|
|
|
752
750
|
* ```tsx
|
|
753
751
|
* const { freeShippingMethods, paymentShippingMethods, nddOverweight, tddOverweight } = useShippingMethods({
|
|
754
752
|
* variant,
|
|
755
|
-
* zipCode,
|
|
756
753
|
* allowNextDayDelivery,
|
|
757
754
|
* allowThirdDayDelivery,
|
|
758
755
|
* plusMemberMetafields,
|
|
759
756
|
* selectedPlusMemberMode,
|
|
760
757
|
* isPlus: profile?.isPlus,
|
|
761
|
-
* nddCoupon,
|
|
762
|
-
* tddCoupon,
|
|
763
758
|
* })
|
|
764
759
|
* ```
|
|
765
760
|
*/
|
|
@@ -1029,13 +1024,20 @@ declare function usePlusMemberNeedAddToCart({ cart, profile, }: {
|
|
|
1029
1024
|
variant: _anker_in_shopify_sdk.NormalizedProductVariant;
|
|
1030
1025
|
} | undefined;
|
|
1031
1026
|
|
|
1027
|
+
declare const useAvailableDeliveryCoupon: ({ profile }: {
|
|
1028
|
+
profile?: any;
|
|
1029
|
+
}) => {
|
|
1030
|
+
nddCoupon: any;
|
|
1031
|
+
tddCoupon: any;
|
|
1032
|
+
isLoading: boolean;
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1032
1035
|
interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any> {
|
|
1033
1036
|
variant: TVariant;
|
|
1034
1037
|
product: TProduct;
|
|
1035
1038
|
memberSetting: PlusMemberSettingsMetafields;
|
|
1036
1039
|
initialSelectedPlusMemberMode?: DeliveryPlusType;
|
|
1037
1040
|
profile?: TProfile;
|
|
1038
|
-
locale?: string;
|
|
1039
1041
|
}
|
|
1040
1042
|
/**
|
|
1041
1043
|
* Plus Member Provider Component
|
|
@@ -1057,13 +1059,14 @@ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any
|
|
|
1057
1059
|
* product={product}
|
|
1058
1060
|
* memberSetting={memberSetting}
|
|
1059
1061
|
* profile={profile}
|
|
1060
|
-
* locale={locale}
|
|
1061
1062
|
* >
|
|
1062
1063
|
* <YourComponent />
|
|
1063
1064
|
* </PlusMemberProvider>
|
|
1064
1065
|
* ```
|
|
1065
1066
|
*/
|
|
1066
|
-
declare const PlusMemberProvider: <TProduct = any, TVariant = any, TProfile
|
|
1067
|
+
declare const PlusMemberProvider: <TProduct = any, TVariant = any, TProfile extends {
|
|
1068
|
+
isPlus?: boolean;
|
|
1069
|
+
} = any>({ variant, product, memberSetting, initialSelectedPlusMemberMode, profile, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
|
|
1067
1070
|
|
|
1068
1071
|
declare const getReferralAttributes: () => {
|
|
1069
1072
|
key: string;
|
|
@@ -1931,4 +1934,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
1931
1934
|
*/
|
|
1932
1935
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
1933
1936
|
|
|
1934
|
-
export { type AddCartLinesInput, AddToCartInput, AddToCartLineItem, type ApplyCartCodesInput, type AutoFreeGift, type AutoFreeGiftCartLineInput, type AutoFreeGiftConfig, type AutoFreeGiftItem, type AutoFreeGiftList, type AutoFreeGiftMainProduct, type BuyNowInput, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, type Config, type CreateCartInput, DeliveryData, DeliveryPlusType, type DiscountLabel, type FormattedGift, type FunctionGiftResult, type GeoLocationData, type GiftProduct, type GiftProductItem, type GiftTier, type HasPlusMemberInCartResult, type ImageMedia, type LocaleMapping, MAIN_PRODUCT_CODE, type MainProductInfo, type NormalizedSearchResultItem, type Options, OrderBasePriceType, type OrderDiscountConfig, type OrderDiscountResult, OrderDiscountType, PlusMemberContext, type PlusMemberContextValue, PlusMemberProvider, type PlusMemberProviderProps, PlusMemberSettingsMetafields, PlusMemberShippingMethodConfig, PriceBasePriceType, type PriceDiscountConfig, PriceDiscountType, type RemoveCartCodesInput, type RemoveCartLinesInput, type RewardItem, type RuleCondition, RuleType, SCRIPT_CODE_AMOUNT_KEY, type SearchResult, type SearchResultType, type SelectedOptionsResult, SelectedPlusMemberProduct, type ShippingMethodsContext, type SiteInfo, SpendMoneyType, type TieredDiscount, type UpdateCartAttributesInput, UseAddToCartOptions, type UseAllBlogsOptions, type UseAllCollectionsOptions, type UseAllProductsOptions, type UseArticleOptions, type UseArticlesInBlogOptions, type UseArticlesOptions, type UseAutoRemovePlusMemberInCartProps, type UseBlogOptions, type UseBuyNowOptions, type UseCalcGiftsFromLinesOptions, type UseCalcGiftsFromLinesResult, type UseCollectionOptions, type UseCollectionsOptions, type UseExposureOptions, type UseGeoLocationOptions, type UseHasPlusMemberInCartProps, type UseIntersectionOptions, type UsePriceOptions, type UsePriceResult, type UseProductOptions, type UseProductsByHandlesOptions, type UseScriptAutoFreeGiftResult, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingMethodsResult, type UseSiteOptions, type UseUpdatePlusMemberDeliveryOptionsProps, type VariantItem, type VariantMedia, type VideoMedia, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, normalizeAddToCartLines, preCheck, safeParse, useAddCartLines, useAddToCart, useAllBlogs, useAllCollections, useAllProducts, useApplyCartCodes, useArticle, useArticles, useArticlesInBlog, useAutoRemovePlusMemberInCart, useBlog, useBuyNow, useCalcAutoFreeGift, useCalcGiftsFromLines, useCalcOrderDiscount, useCartAttributes, useCartItemQuantityLimit, useCollection, useCollections, useCreateCart, useExposure, useGeoLocation, useHasPlusMemberInCart, useIntersection, usePlusAnnualProductVariant, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberDeliveryCodes, usePlusMemberItemCustomAttributes, usePlusMemberNeedAddToCart, usePlusMonthlyProductVariant, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethodAvailableCheck, useShippingMethods, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdatePlusMemberDeliveryOptions, useUpdateVariantQuery, useVariant, useVariantMedia };
|
|
1937
|
+
export { type AddCartLinesInput, AddToCartInput, AddToCartLineItem, type ApplyCartCodesInput, type AutoFreeGift, type AutoFreeGiftCartLineInput, type AutoFreeGiftConfig, type AutoFreeGiftItem, type AutoFreeGiftList, type AutoFreeGiftMainProduct, type BuyNowInput, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, type Config, type CreateCartInput, DeliveryData, DeliveryPlusType, type DiscountLabel, type FormattedGift, type FunctionGiftResult, type GeoLocationData, type GiftProduct, type GiftProductItem, type GiftTier, type HasPlusMemberInCartResult, type ImageMedia, type LocaleMapping, MAIN_PRODUCT_CODE, type MainProductInfo, type NormalizedSearchResultItem, type Options, OrderBasePriceType, type OrderDiscountConfig, type OrderDiscountResult, OrderDiscountType, PlusMemberContext, type PlusMemberContextValue, PlusMemberProvider, type PlusMemberProviderProps, PlusMemberSettingsMetafields, PlusMemberShippingMethodConfig, PriceBasePriceType, type PriceDiscountConfig, PriceDiscountType, type RemoveCartCodesInput, type RemoveCartLinesInput, type RewardItem, type RuleCondition, RuleType, SCRIPT_CODE_AMOUNT_KEY, type SearchResult, type SearchResultType, type SelectedOptionsResult, SelectedPlusMemberProduct, type ShippingMethodsContext, type SiteInfo, SpendMoneyType, type TieredDiscount, type UpdateCartAttributesInput, UseAddToCartOptions, type UseAllBlogsOptions, type UseAllCollectionsOptions, type UseAllProductsOptions, type UseArticleOptions, type UseArticlesInBlogOptions, type UseArticlesOptions, type UseAutoRemovePlusMemberInCartProps, type UseBlogOptions, type UseBuyNowOptions, type UseCalcGiftsFromLinesOptions, type UseCalcGiftsFromLinesResult, type UseCollectionOptions, type UseCollectionsOptions, type UseExposureOptions, type UseGeoLocationOptions, type UseHasPlusMemberInCartProps, type UseIntersectionOptions, type UsePriceOptions, type UsePriceResult, type UseProductOptions, type UseProductsByHandlesOptions, type UseScriptAutoFreeGiftResult, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingMethodsResult, type UseSiteOptions, type UseUpdatePlusMemberDeliveryOptionsProps, type VariantItem, type VariantMedia, type VideoMedia, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, 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, usePlusAnnualProductVariant, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberDeliveryCodes, usePlusMemberItemCustomAttributes, usePlusMemberNeedAddToCart, usePlusMonthlyProductVariant, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethodAvailableCheck, useShippingMethods, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdatePlusMemberDeliveryOptions, useUpdateVariantQuery, useVariant, useVariantMedia };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -719,8 +719,6 @@ declare function usePlusAnnualProductVariant<TVariant = any>(): TVariant | undef
|
|
|
719
719
|
interface UseShippingMethodsOptions<TVariant = any> {
|
|
720
720
|
/** Product variant with weight information */
|
|
721
721
|
variant: TVariant;
|
|
722
|
-
/** Zip code for delivery */
|
|
723
|
-
zipCode: string;
|
|
724
722
|
/** Whether next day delivery is allowed */
|
|
725
723
|
allowNextDayDelivery: boolean;
|
|
726
724
|
/** Whether third day delivery is allowed */
|
|
@@ -731,16 +729,16 @@ interface UseShippingMethodsOptions<TVariant = any> {
|
|
|
731
729
|
selectedPlusMemberMode: DeliveryPlusType;
|
|
732
730
|
/** Whether user is a plus member */
|
|
733
731
|
isPlus?: boolean;
|
|
734
|
-
|
|
735
|
-
nddCoupon?: string;
|
|
736
|
-
/** Available TDD coupon code */
|
|
737
|
-
tddCoupon?: string;
|
|
732
|
+
profile?: any;
|
|
738
733
|
}
|
|
739
734
|
interface UseShippingMethodsResult {
|
|
740
735
|
freeShippingMethods: PlusMemberShippingMethodConfig[];
|
|
741
736
|
paymentShippingMethods: PlusMemberShippingMethodConfig[];
|
|
742
737
|
nddOverweight: boolean;
|
|
743
738
|
tddOverweight: boolean;
|
|
739
|
+
nddCoupon?: string;
|
|
740
|
+
tddCoupon?: string;
|
|
741
|
+
isLoadingCoupon: boolean;
|
|
744
742
|
}
|
|
745
743
|
/**
|
|
746
744
|
* Calculate available shipping methods based on product weight, member status, and available coupons
|
|
@@ -752,14 +750,11 @@ interface UseShippingMethodsResult {
|
|
|
752
750
|
* ```tsx
|
|
753
751
|
* const { freeShippingMethods, paymentShippingMethods, nddOverweight, tddOverweight } = useShippingMethods({
|
|
754
752
|
* variant,
|
|
755
|
-
* zipCode,
|
|
756
753
|
* allowNextDayDelivery,
|
|
757
754
|
* allowThirdDayDelivery,
|
|
758
755
|
* plusMemberMetafields,
|
|
759
756
|
* selectedPlusMemberMode,
|
|
760
757
|
* isPlus: profile?.isPlus,
|
|
761
|
-
* nddCoupon,
|
|
762
|
-
* tddCoupon,
|
|
763
758
|
* })
|
|
764
759
|
* ```
|
|
765
760
|
*/
|
|
@@ -1029,13 +1024,20 @@ declare function usePlusMemberNeedAddToCart({ cart, profile, }: {
|
|
|
1029
1024
|
variant: _anker_in_shopify_sdk.NormalizedProductVariant;
|
|
1030
1025
|
} | undefined;
|
|
1031
1026
|
|
|
1027
|
+
declare const useAvailableDeliveryCoupon: ({ profile }: {
|
|
1028
|
+
profile?: any;
|
|
1029
|
+
}) => {
|
|
1030
|
+
nddCoupon: any;
|
|
1031
|
+
tddCoupon: any;
|
|
1032
|
+
isLoading: boolean;
|
|
1033
|
+
};
|
|
1034
|
+
|
|
1032
1035
|
interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any> {
|
|
1033
1036
|
variant: TVariant;
|
|
1034
1037
|
product: TProduct;
|
|
1035
1038
|
memberSetting: PlusMemberSettingsMetafields;
|
|
1036
1039
|
initialSelectedPlusMemberMode?: DeliveryPlusType;
|
|
1037
1040
|
profile?: TProfile;
|
|
1038
|
-
locale?: string;
|
|
1039
1041
|
}
|
|
1040
1042
|
/**
|
|
1041
1043
|
* Plus Member Provider Component
|
|
@@ -1057,13 +1059,14 @@ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any
|
|
|
1057
1059
|
* product={product}
|
|
1058
1060
|
* memberSetting={memberSetting}
|
|
1059
1061
|
* profile={profile}
|
|
1060
|
-
* locale={locale}
|
|
1061
1062
|
* >
|
|
1062
1063
|
* <YourComponent />
|
|
1063
1064
|
* </PlusMemberProvider>
|
|
1064
1065
|
* ```
|
|
1065
1066
|
*/
|
|
1066
|
-
declare const PlusMemberProvider: <TProduct = any, TVariant = any, TProfile
|
|
1067
|
+
declare const PlusMemberProvider: <TProduct = any, TVariant = any, TProfile extends {
|
|
1068
|
+
isPlus?: boolean;
|
|
1069
|
+
} = any>({ variant, product, memberSetting, initialSelectedPlusMemberMode, profile, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
|
|
1067
1070
|
|
|
1068
1071
|
declare const getReferralAttributes: () => {
|
|
1069
1072
|
key: string;
|
|
@@ -1931,4 +1934,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
1931
1934
|
*/
|
|
1932
1935
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
1933
1936
|
|
|
1934
|
-
export { type AddCartLinesInput, AddToCartInput, AddToCartLineItem, type ApplyCartCodesInput, type AutoFreeGift, type AutoFreeGiftCartLineInput, type AutoFreeGiftConfig, type AutoFreeGiftItem, type AutoFreeGiftList, type AutoFreeGiftMainProduct, type BuyNowInput, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, type Config, type CreateCartInput, DeliveryData, DeliveryPlusType, type DiscountLabel, type FormattedGift, type FunctionGiftResult, type GeoLocationData, type GiftProduct, type GiftProductItem, type GiftTier, type HasPlusMemberInCartResult, type ImageMedia, type LocaleMapping, MAIN_PRODUCT_CODE, type MainProductInfo, type NormalizedSearchResultItem, type Options, OrderBasePriceType, type OrderDiscountConfig, type OrderDiscountResult, OrderDiscountType, PlusMemberContext, type PlusMemberContextValue, PlusMemberProvider, type PlusMemberProviderProps, PlusMemberSettingsMetafields, PlusMemberShippingMethodConfig, PriceBasePriceType, type PriceDiscountConfig, PriceDiscountType, type RemoveCartCodesInput, type RemoveCartLinesInput, type RewardItem, type RuleCondition, RuleType, SCRIPT_CODE_AMOUNT_KEY, type SearchResult, type SearchResultType, type SelectedOptionsResult, SelectedPlusMemberProduct, type ShippingMethodsContext, type SiteInfo, SpendMoneyType, type TieredDiscount, type UpdateCartAttributesInput, UseAddToCartOptions, type UseAllBlogsOptions, type UseAllCollectionsOptions, type UseAllProductsOptions, type UseArticleOptions, type UseArticlesInBlogOptions, type UseArticlesOptions, type UseAutoRemovePlusMemberInCartProps, type UseBlogOptions, type UseBuyNowOptions, type UseCalcGiftsFromLinesOptions, type UseCalcGiftsFromLinesResult, type UseCollectionOptions, type UseCollectionsOptions, type UseExposureOptions, type UseGeoLocationOptions, type UseHasPlusMemberInCartProps, type UseIntersectionOptions, type UsePriceOptions, type UsePriceResult, type UseProductOptions, type UseProductsByHandlesOptions, type UseScriptAutoFreeGiftResult, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingMethodsResult, type UseSiteOptions, type UseUpdatePlusMemberDeliveryOptionsProps, type VariantItem, type VariantMedia, type VideoMedia, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, normalizeAddToCartLines, preCheck, safeParse, useAddCartLines, useAddToCart, useAllBlogs, useAllCollections, useAllProducts, useApplyCartCodes, useArticle, useArticles, useArticlesInBlog, useAutoRemovePlusMemberInCart, useBlog, useBuyNow, useCalcAutoFreeGift, useCalcGiftsFromLines, useCalcOrderDiscount, useCartAttributes, useCartItemQuantityLimit, useCollection, useCollections, useCreateCart, useExposure, useGeoLocation, useHasPlusMemberInCart, useIntersection, usePlusAnnualProductVariant, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberDeliveryCodes, usePlusMemberItemCustomAttributes, usePlusMemberNeedAddToCart, usePlusMonthlyProductVariant, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethodAvailableCheck, useShippingMethods, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdatePlusMemberDeliveryOptions, useUpdateVariantQuery, useVariant, useVariantMedia };
|
|
1937
|
+
export { type AddCartLinesInput, AddToCartInput, AddToCartLineItem, type ApplyCartCodesInput, type AutoFreeGift, type AutoFreeGiftCartLineInput, type AutoFreeGiftConfig, type AutoFreeGiftItem, type AutoFreeGiftList, type AutoFreeGiftMainProduct, type BuyNowInput, BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, type Config, type CreateCartInput, DeliveryData, DeliveryPlusType, type DiscountLabel, type FormattedGift, type FunctionGiftResult, type GeoLocationData, type GiftProduct, type GiftProductItem, type GiftTier, type HasPlusMemberInCartResult, type ImageMedia, type LocaleMapping, MAIN_PRODUCT_CODE, type MainProductInfo, type NormalizedSearchResultItem, type Options, OrderBasePriceType, type OrderDiscountConfig, type OrderDiscountResult, OrderDiscountType, PlusMemberContext, type PlusMemberContextValue, PlusMemberProvider, type PlusMemberProviderProps, PlusMemberSettingsMetafields, PlusMemberShippingMethodConfig, PriceBasePriceType, type PriceDiscountConfig, PriceDiscountType, type RemoveCartCodesInput, type RemoveCartLinesInput, type RewardItem, type RuleCondition, RuleType, SCRIPT_CODE_AMOUNT_KEY, type SearchResult, type SearchResultType, type SelectedOptionsResult, SelectedPlusMemberProduct, type ShippingMethodsContext, type SiteInfo, SpendMoneyType, type TieredDiscount, type UpdateCartAttributesInput, UseAddToCartOptions, type UseAllBlogsOptions, type UseAllCollectionsOptions, type UseAllProductsOptions, type UseArticleOptions, type UseArticlesInBlogOptions, type UseArticlesOptions, type UseAutoRemovePlusMemberInCartProps, type UseBlogOptions, type UseBuyNowOptions, type UseCalcGiftsFromLinesOptions, type UseCalcGiftsFromLinesResult, type UseCollectionOptions, type UseCollectionsOptions, type UseExposureOptions, type UseGeoLocationOptions, type UseHasPlusMemberInCartProps, type UseIntersectionOptions, type UsePriceOptions, type UsePriceResult, type UseProductOptions, type UseProductsByHandlesOptions, type UseScriptAutoFreeGiftResult, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingMethodsResult, type UseSiteOptions, type UseUpdatePlusMemberDeliveryOptionsProps, type VariantItem, type VariantMedia, type VideoMedia, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, 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, usePlusAnnualProductVariant, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberDeliveryCodes, usePlusMemberItemCustomAttributes, usePlusMemberNeedAddToCart, usePlusMonthlyProductVariant, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethodAvailableCheck, useShippingMethods, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdatePlusMemberDeliveryOptions, useUpdateVariantQuery, useVariant, useVariantMedia };
|
package/dist/hooks/index.js
CHANGED
|
@@ -397,54 +397,28 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
397
397
|
}
|
|
398
398
|
return { activeCampaign: null, subtotal: 0 };
|
|
399
399
|
}, [autoFreeGiftConfig, effectiveCart, tags, dealsType]);
|
|
400
|
-
const {
|
|
400
|
+
const { qualifyingTier, nextTierGoal, actualThreshold, currentCurrency } = react.useMemo(() => {
|
|
401
401
|
if (!activeCampaign || !activeCampaign.rule_result?.spend_get_reward?.gift_product) {
|
|
402
|
-
return {
|
|
402
|
+
return { qualifyingTier: null, nextTierGoal: null, actualThreshold: 0, currentCurrency: "" };
|
|
403
403
|
}
|
|
404
404
|
const giftTiers = activeCampaign.rule_result.spend_get_reward.gift_product;
|
|
405
|
-
const
|
|
406
|
-
console.log("currentCurrency useCalcAutoFreeGift", effectiveCart,
|
|
405
|
+
const currentCurrency2 = effectiveCart?.currency?.code || "";
|
|
406
|
+
console.log("currentCurrency useCalcAutoFreeGift", effectiveCart, currentCurrency2);
|
|
407
407
|
const getThresholdAmount = (tier) => {
|
|
408
|
-
if (tier.spend_sum_money_multi_markets?.[
|
|
409
|
-
return Number(tier.spend_sum_money_multi_markets[
|
|
408
|
+
if (tier.spend_sum_money_multi_markets?.[currentCurrency2]?.value) {
|
|
409
|
+
return Number(tier.spend_sum_money_multi_markets[currentCurrency2].value);
|
|
410
410
|
}
|
|
411
411
|
return Number(tier.spend_sum_money || 0);
|
|
412
412
|
};
|
|
413
|
-
const
|
|
413
|
+
const qualifyingTier2 = [...giftTiers].sort((a, b) => getThresholdAmount(b) - getThresholdAmount(a)).find((tier) => subtotal >= getThresholdAmount(tier));
|
|
414
414
|
const nextGoal = giftTiers.find((tier) => subtotal < getThresholdAmount(tier));
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
itemsToAdd: qualifyingTier.reward_list?.map((reward) => {
|
|
422
|
-
const giftProduct = reward?.variant_list?.[0];
|
|
423
|
-
if (!giftProduct) return null;
|
|
424
|
-
return {
|
|
425
|
-
variant: {
|
|
426
|
-
id: shopifyCore.btoaID(giftProduct.variant_id),
|
|
427
|
-
handle: giftProduct.handle,
|
|
428
|
-
sku: giftProduct.sku
|
|
429
|
-
},
|
|
430
|
-
quantity: reward?.get_unit || 1,
|
|
431
|
-
attributes: [
|
|
432
|
-
{
|
|
433
|
-
key: CUSTOMER_ATTRIBUTE_KEY,
|
|
434
|
-
value: JSON.stringify({
|
|
435
|
-
is_gift: true,
|
|
436
|
-
rule_id: activeCampaign.rule_id,
|
|
437
|
-
spend_sum_money: actualThreshold,
|
|
438
|
-
// 使用实际的门槛金额(多币种支持)
|
|
439
|
-
currency_code: currentCurrency
|
|
440
|
-
// 记录当前币种
|
|
441
|
-
})
|
|
442
|
-
}
|
|
443
|
-
]
|
|
444
|
-
};
|
|
445
|
-
}).filter((item) => item !== null)
|
|
415
|
+
const actualThreshold2 = qualifyingTier2 ? getThresholdAmount(qualifyingTier2) : 0;
|
|
416
|
+
return {
|
|
417
|
+
qualifyingTier: qualifyingTier2,
|
|
418
|
+
nextTierGoal: nextGoal || null,
|
|
419
|
+
actualThreshold: actualThreshold2,
|
|
420
|
+
currentCurrency: currentCurrency2
|
|
446
421
|
};
|
|
447
|
-
return { qualifyingGift: formattedGift, nextTierGoal: nextGoal || null };
|
|
448
422
|
}, [activeCampaign, subtotal, effectiveCart]);
|
|
449
423
|
const giftHandles = react.useMemo(() => {
|
|
450
424
|
const giftVariant = autoFreeGiftConfig.map(
|
|
@@ -485,6 +459,58 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
485
459
|
}
|
|
486
460
|
return giftProductsResult;
|
|
487
461
|
}, [giftProductsResult, shouldFetch]);
|
|
462
|
+
const qualifyingGift = react.useMemo(() => {
|
|
463
|
+
if (!qualifyingTier || !activeCampaign) {
|
|
464
|
+
return null;
|
|
465
|
+
}
|
|
466
|
+
const itemsToAdd = qualifyingTier.reward_list?.map((reward) => {
|
|
467
|
+
if (!reward.variant_list || reward.variant_list.length === 0) {
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
let selectedGiftProduct = null;
|
|
471
|
+
for (const giftVariant of reward.variant_list) {
|
|
472
|
+
const productInfo = finalGiftProductsResult?.find(
|
|
473
|
+
(p) => p.handle === giftVariant.handle
|
|
474
|
+
);
|
|
475
|
+
if (productInfo) {
|
|
476
|
+
const variantInfo = productInfo.variants?.find((v) => v.sku === giftVariant.sku);
|
|
477
|
+
if (variantInfo?.availableForSale) {
|
|
478
|
+
selectedGiftProduct = giftVariant;
|
|
479
|
+
break;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (!selectedGiftProduct) {
|
|
484
|
+
selectedGiftProduct = reward.variant_list[0];
|
|
485
|
+
}
|
|
486
|
+
return {
|
|
487
|
+
variant: {
|
|
488
|
+
id: shopifyCore.btoaID(selectedGiftProduct.variant_id),
|
|
489
|
+
handle: selectedGiftProduct.handle,
|
|
490
|
+
sku: selectedGiftProduct.sku
|
|
491
|
+
},
|
|
492
|
+
quantity: reward?.get_unit || 1,
|
|
493
|
+
attributes: [
|
|
494
|
+
{
|
|
495
|
+
key: CUSTOMER_ATTRIBUTE_KEY,
|
|
496
|
+
value: JSON.stringify({
|
|
497
|
+
is_gift: true,
|
|
498
|
+
rule_id: activeCampaign.rule_id,
|
|
499
|
+
spend_sum_money: actualThreshold,
|
|
500
|
+
// 使用实际的门槛金额(多币种支持)
|
|
501
|
+
currency_code: currentCurrency
|
|
502
|
+
// 记录当前币种
|
|
503
|
+
})
|
|
504
|
+
}
|
|
505
|
+
]
|
|
506
|
+
};
|
|
507
|
+
}).filter((item) => item !== null);
|
|
508
|
+
const formattedGift = {
|
|
509
|
+
tier: qualifyingTier,
|
|
510
|
+
itemsToAdd
|
|
511
|
+
};
|
|
512
|
+
return formattedGift;
|
|
513
|
+
}, [qualifyingTier, activeCampaign, finalGiftProductsResult, actualThreshold, currentCurrency]);
|
|
488
514
|
return {
|
|
489
515
|
qualifyingGift,
|
|
490
516
|
nextTierGoal,
|
|
@@ -2426,15 +2452,27 @@ function usePlusAnnualProductVariant() {
|
|
|
2426
2452
|
}, [plusMemberProducts, plusAnnual]);
|
|
2427
2453
|
return plusAnnualProductVariant;
|
|
2428
2454
|
}
|
|
2429
|
-
|
|
2430
|
-
const {
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2455
|
+
var useAvailableDeliveryCoupon = ({ profile }) => {
|
|
2456
|
+
const { data: availableDeliveryCoupon, isLoading } = useSWR__default.default(
|
|
2457
|
+
profile?.email ? ["/api/multipass/subsrv/v1/prime/delivery_coupons/current/available", profile?.email] : void 0,
|
|
2458
|
+
async ([apiPath]) => {
|
|
2459
|
+
return fetch(apiPath).then((res) => res.json());
|
|
2460
|
+
}
|
|
2461
|
+
);
|
|
2462
|
+
console.log("availableDeliveryCoupon", availableDeliveryCoupon);
|
|
2463
|
+
const { ndd_coupon: nddCoupon, tdd_coupon: tddCoupon } = availableDeliveryCoupon?.data?.data || {};
|
|
2464
|
+
return {
|
|
2435
2465
|
nddCoupon,
|
|
2436
|
-
tddCoupon
|
|
2437
|
-
|
|
2466
|
+
tddCoupon,
|
|
2467
|
+
isLoading
|
|
2468
|
+
};
|
|
2469
|
+
};
|
|
2470
|
+
|
|
2471
|
+
// src/hooks/member/plus/use-shipping-methods.ts
|
|
2472
|
+
function useShippingMethods(options) {
|
|
2473
|
+
const { variant, plusMemberMetafields, selectedPlusMemberMode, isPlus = false, profile } = options;
|
|
2474
|
+
const { nddCoupon, tddCoupon, isLoading } = useAvailableDeliveryCoupon({ profile });
|
|
2475
|
+
console.log("nddCoupon", nddCoupon);
|
|
2438
2476
|
const { plus_shipping, shippingMethod } = plusMemberMetafields || {};
|
|
2439
2477
|
const nddOverweight = react.useMemo(() => {
|
|
2440
2478
|
return (variant?.weight || 0) > (shippingMethod?.overWeight_ndd || Infinity);
|
|
@@ -2444,12 +2482,10 @@ function useShippingMethods(options) {
|
|
|
2444
2482
|
}, [shippingMethod?.overWeight_tdd, variant?.weight]);
|
|
2445
2483
|
const paymentShippingMethods = react.useMemo(() => {
|
|
2446
2484
|
const weight = variant?.weight || 0;
|
|
2447
|
-
const methods = plus_shipping?.shipping_methods?.filter(
|
|
2448
|
-
(
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
}
|
|
2452
|
-
) || [];
|
|
2485
|
+
const methods = plus_shipping?.shipping_methods?.filter(({ weight_low, weight_high, __mode, __plus }) => {
|
|
2486
|
+
const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
|
|
2487
|
+
return __mode !== "free" /* FREE */ && !__plus && fitWeight;
|
|
2488
|
+
}) || [];
|
|
2453
2489
|
return methods.map((method) => {
|
|
2454
2490
|
let disabled = false;
|
|
2455
2491
|
const selectedFreeMember = selectedPlusMemberMode === "free";
|
|
@@ -2476,40 +2512,34 @@ function useShippingMethods(options) {
|
|
|
2476
2512
|
]);
|
|
2477
2513
|
const nddPrice = react.useMemo(() => {
|
|
2478
2514
|
const weight = variant?.weight || 0;
|
|
2479
|
-
const nddMethod = paymentShippingMethods.find(
|
|
2480
|
-
(
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
}
|
|
2484
|
-
);
|
|
2515
|
+
const nddMethod = paymentShippingMethods.find(({ __mode, weight_high, weight_low }) => {
|
|
2516
|
+
const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
|
|
2517
|
+
return __mode === "ndd" && fitWeight;
|
|
2518
|
+
});
|
|
2485
2519
|
return nddMethod?.price || 0;
|
|
2486
2520
|
}, [variant?.weight, paymentShippingMethods]);
|
|
2487
2521
|
const tddPrice = react.useMemo(() => {
|
|
2488
2522
|
const weight = variant?.weight || 0;
|
|
2489
|
-
const tddMethod = paymentShippingMethods.find(
|
|
2490
|
-
(
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
}
|
|
2494
|
-
);
|
|
2523
|
+
const tddMethod = paymentShippingMethods.find(({ __mode, weight_high, weight_low }) => {
|
|
2524
|
+
const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
|
|
2525
|
+
return __mode === "tdd" && fitWeight;
|
|
2526
|
+
});
|
|
2495
2527
|
return tddMethod?.price || 0;
|
|
2496
2528
|
}, [variant?.weight, paymentShippingMethods]);
|
|
2497
2529
|
const freeShippingMethods = react.useMemo(() => {
|
|
2498
2530
|
const weight = variant?.weight || 0;
|
|
2499
|
-
let methods = plus_shipping?.shipping_methods?.filter(
|
|
2500
|
-
(
|
|
2501
|
-
|
|
2502
|
-
return true;
|
|
2503
|
-
}
|
|
2504
|
-
if (isPlus) {
|
|
2505
|
-
const hasCoupon = isPlus && __mode === "ndd" /* NDD */ && nddCoupon || isPlus && __mode === "tdd" /* TDD */ && (tddCoupon || nddCoupon);
|
|
2506
|
-
const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
|
|
2507
|
-
return hasCoupon && fitWeight && !__plus;
|
|
2508
|
-
} else {
|
|
2509
|
-
return __plus;
|
|
2510
|
-
}
|
|
2531
|
+
let methods = plus_shipping?.shipping_methods?.filter(({ __mode, __plus, weight_low, weight_high }) => {
|
|
2532
|
+
if (__mode === "free" /* FREE */) {
|
|
2533
|
+
return true;
|
|
2511
2534
|
}
|
|
2512
|
-
|
|
2535
|
+
if (isPlus) {
|
|
2536
|
+
const hasCoupon = isPlus && __mode === "ndd" /* NDD */ && nddCoupon || isPlus && __mode === "tdd" /* TDD */ && (tddCoupon || nddCoupon);
|
|
2537
|
+
const fitWeight = (!weight_low || weight >= weight_low) && (!weight_high || weight <= weight_high);
|
|
2538
|
+
return hasCoupon && fitWeight && !__plus;
|
|
2539
|
+
} else {
|
|
2540
|
+
return __plus;
|
|
2541
|
+
}
|
|
2542
|
+
}) || [];
|
|
2513
2543
|
if (isPlus) {
|
|
2514
2544
|
methods = methods.sort((a, b) => {
|
|
2515
2545
|
if (b.__mode === "free" /* FREE */) return -1;
|
|
@@ -2563,7 +2593,10 @@ function useShippingMethods(options) {
|
|
|
2563
2593
|
freeShippingMethods,
|
|
2564
2594
|
paymentShippingMethods,
|
|
2565
2595
|
nddOverweight,
|
|
2566
|
-
tddOverweight
|
|
2596
|
+
tddOverweight,
|
|
2597
|
+
nddCoupon,
|
|
2598
|
+
tddCoupon,
|
|
2599
|
+
isLoadingCoupon: isLoading
|
|
2567
2600
|
};
|
|
2568
2601
|
}
|
|
2569
2602
|
function useShippingMethodAvailableCheck() {
|
|
@@ -2853,9 +2886,9 @@ var PlusMemberProvider = ({
|
|
|
2853
2886
|
memberSetting,
|
|
2854
2887
|
initialSelectedPlusMemberMode = "free",
|
|
2855
2888
|
profile,
|
|
2856
|
-
locale,
|
|
2857
2889
|
children
|
|
2858
2890
|
}) => {
|
|
2891
|
+
const { locale } = useShopify();
|
|
2859
2892
|
const [zipCode, setZipCode] = react.useState("");
|
|
2860
2893
|
const [showTip, setShowTip] = react.useState(false);
|
|
2861
2894
|
const [selectedPlusMemberMode, setSelectedPlusMemberMode] = react.useState(
|
|
@@ -2871,7 +2904,11 @@ var PlusMemberProvider = ({
|
|
|
2871
2904
|
const shippingMethodsContext = useShippingMethods({
|
|
2872
2905
|
variant,
|
|
2873
2906
|
plusMemberMetafields: memberSetting,
|
|
2874
|
-
selectedPlusMemberMode
|
|
2907
|
+
selectedPlusMemberMode,
|
|
2908
|
+
profile,
|
|
2909
|
+
isPlus: profile?.isPlus || false
|
|
2910
|
+
});
|
|
2911
|
+
console.log("shippingMethodsContext", shippingMethodsContext);
|
|
2875
2912
|
const plusMemberHandles = react.useMemo(() => {
|
|
2876
2913
|
return [
|
|
2877
2914
|
memberSetting?.plus_monthly_product?.handle,
|
|
@@ -3151,6 +3188,7 @@ exports.useArticle = useArticle;
|
|
|
3151
3188
|
exports.useArticles = useArticles;
|
|
3152
3189
|
exports.useArticlesInBlog = useArticlesInBlog;
|
|
3153
3190
|
exports.useAutoRemovePlusMemberInCart = useAutoRemovePlusMemberInCart;
|
|
3191
|
+
exports.useAvailableDeliveryCoupon = useAvailableDeliveryCoupon;
|
|
3154
3192
|
exports.useBlog = useBlog;
|
|
3155
3193
|
exports.useBuyNow = useBuyNow;
|
|
3156
3194
|
exports.useCalcAutoFreeGift = useCalcAutoFreeGift;
|