@anker-in/shopify-react 0.1.1-beta.43 → 0.1.1-beta.44

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.
@@ -2,14 +2,14 @@ import * as swr_mutation from 'swr/mutation';
2
2
  import { SWRMutationConfiguration } from 'swr/mutation';
3
3
  import * as _anker_in_shopify_sdk from '@anker-in/shopify-sdk';
4
4
  import { CartLineInput, NormalizedCart, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedAttribute, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
5
- import { U as UseAddToCartOptions, a as AddToCartInput, A as AddToCartLineItem, G as GtmParams, B as BuyNowTrackConfig, d as PlusMemberShippingMethodConfig, e as PlusMemberSettingsMetafields, D as DeliveryPlusType, f as SelectedPlusMemberVariant } from '../types-CMMWxyUF.mjs';
5
+ import { U as UseAddToCartOptions, a as AddToCartInput, A as AddToCartLineItem, G as GtmParams, B as BuyNowTrackConfig, e as PlusMemberSettingsMetafields, d as PlusMemberShippingMethodConfig, D as DeliveryPlusType, f as SelectedPlusMemberVariant } from '../types-CMMWxyUF.mjs';
6
6
  export { g as DeliveryCustomData, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, c as PlusMemberShippingMethodMetafields, S as ShippingMethodMode } from '../types-CMMWxyUF.mjs';
7
7
  import Decimal from 'decimal.js';
8
8
  import * as swr from 'swr';
9
9
  import swr__default, { SWRConfiguration } from 'swr';
10
10
  import * as swr__internal from 'swr/_internal';
11
11
  import * as React$1 from 'react';
12
- import { PropsWithChildren, Dispatch, SetStateAction, RefObject } from 'react';
12
+ import { Dispatch, SetStateAction, PropsWithChildren, RefObject } from 'react';
13
13
  import * as react_jsx_runtime from 'react/jsx-runtime';
14
14
 
15
15
  interface CreateCartInput {
@@ -57,7 +57,10 @@ interface CreateCartInput {
57
57
  * })
58
58
  * ```
59
59
  */
60
- declare function useCreateCart(options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'create-cart', CreateCartInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "create-cart", CreateCartInput>;
60
+ declare function useCreateCart({ updateCookie, options, }: {
61
+ updateCookie?: boolean;
62
+ options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'create-cart', CreateCartInput>;
63
+ }): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "create-cart", CreateCartInput>;
61
64
 
62
65
  interface AddCartLinesInput {
63
66
  /** Cart ID (optional, will create new cart if not provided) */
@@ -585,6 +588,7 @@ interface Campaign {
585
588
  }>;
586
589
  includeTags?: string[];
587
590
  useTotalAmount?: boolean;
591
+ requireLogin?: boolean;
588
592
  }
589
593
  interface UseScriptAutoFreeGiftResult {
590
594
  involvedLines: NormalizedLineItem[];
@@ -595,12 +599,13 @@ interface UseScriptAutoFreeGiftResult {
595
599
  involvedSubTotal: Decimal;
596
600
  giftProductsResult?: NormalizedProduct[];
597
601
  }
598
- declare const useScriptAutoFreeGift: ({ campaign, _giveaway, cart, locale: providedLocale, lines, }: {
602
+ declare const useScriptAutoFreeGift: ({ campaign, _giveaway, cart, locale: providedLocale, lines, profile, }: {
599
603
  campaign: Campaign | null;
600
604
  _giveaway: string;
601
605
  cart: NormalizedCart | undefined;
602
606
  locale?: string;
603
607
  lines?: AddToCartLineItem[];
608
+ profile?: any;
604
609
  }) => UseScriptAutoFreeGiftResult;
605
610
 
606
611
  interface UseCalcGiftsFromLinesOptions {
@@ -685,223 +690,90 @@ interface OrderDiscountResult {
685
690
  */
686
691
  declare const useCalcOrderDiscount: (cart: any, orderDiscountConfig?: OrderDiscountConfig[], customer?: any) => OrderDiscountResult;
687
692
 
688
- interface ShippingMethodsContext {
689
- freeShippingMethods: PlusMemberShippingMethodConfig[];
690
- paymentShippingMethods: PlusMemberShippingMethodConfig[];
691
- nddOverweight: boolean;
692
- tddOverweight: boolean;
693
- nddCoupon?: string;
694
- tddCoupon?: string;
695
- isLoadingCoupon: boolean;
696
- }
697
- interface PlusMemberContextValue<TProduct = any, TVariant = any, TProfile extends {
698
- isPlus?: boolean;
699
- } = any> {
700
- plusMemberMetafields: PlusMemberSettingsMetafields;
701
- selectedPlusMemberMode: DeliveryPlusType;
702
- setSelectedPlusMemberMode: (value: DeliveryPlusType) => void;
703
- selectedShippingMethod?: PlusMemberShippingMethodConfig;
704
- setSelectedShippingMethod: (value: PlusMemberShippingMethodConfig) => void;
705
- showMoreShippingMethod: boolean;
706
- setShowMoreShippingMethod: (value: boolean) => void;
707
- variant: TVariant;
708
- product: TProduct;
709
- shippingMethodsContext: ShippingMethodsContext;
710
- selectedPlusMemberVariant: SelectedPlusMemberVariant;
711
- showPlusMemberBenefit: boolean;
712
- setShowPlusMemberBenefit: (value: boolean) => void;
713
- profile?: TProfile;
714
- }
715
- declare const PlusMemberContext: React$1.Context<PlusMemberContextValue<any, any, any>>;
716
-
717
- /**
718
- * Hook to access Plus Member Context
719
- */
720
- declare function usePlusMemberContext<TProfile extends {
721
- isPlus?: boolean;
722
- } = any>(): PlusMemberContextValue<any, any, any>;
723
-
724
- /**
725
- * Hook to get Plus Member Product Variants (Monthly and Annual)
726
- */
727
-
728
- interface UsePlusMemberVariantsOptions {
729
- /** Plus member metafields configuration */
730
- memberSetting: PlusMemberSettingsMetafields;
731
- }
732
- interface UsePlusMemberVariantsResult {
733
- monthlyVariant?: NormalizedProductVariant & {
734
- product: NormalizedProduct | undefined;
735
- };
736
- annualVariant?: NormalizedProductVariant & {
737
- product: NormalizedProduct | undefined;
738
- };
739
- }
740
- /**
741
- * Get Plus Member product variants (monthly and annual)
742
- *
743
- * @param options - Configuration options
744
- * @returns Monthly and annual variants
745
- *
746
- * @example
747
- * ```tsx
748
- * const { monthlyVariant, annualVariant } = usePlusMemberVariants({
749
- * plusMemberMetafields
750
- * })
751
- * ```
752
- */
753
- declare function usePlusMemberVariants({ memberSetting, }: UsePlusMemberVariantsOptions): UsePlusMemberVariantsResult;
754
-
693
+ declare const getReferralAttributes: () => {
694
+ key: string;
695
+ value: any;
696
+ }[];
755
697
  /**
756
- * Hook to calculate available shipping methods based on product weight and member status
698
+ * Get user type based on customer information
757
699
  */
758
-
759
- interface UseShippingMethodsOptions<TVariant = any, TProfile extends {
760
- isPlus?: boolean;
761
- } = any> {
762
- /** Product variant with weight information */
763
- variant: TVariant;
764
- /** Plus member metafields configuration */
765
- plusMemberMetafields: PlusMemberSettingsMetafields;
766
- /** Selected plus member mode */
767
- selectedPlusMemberMode: DeliveryPlusType;
768
- profile?: TProfile;
769
- }
770
- interface UseShippingMethodsResult {
771
- freeShippingMethods: PlusMemberShippingMethodConfig[];
772
- paymentShippingMethods: PlusMemberShippingMethodConfig[];
773
- nddOverweight: boolean;
774
- tddOverweight: boolean;
775
- nddCoupon?: string;
776
- tddCoupon?: string;
777
- isLoadingCoupon: boolean;
700
+ declare const getUserType: (customer?: any) => string;
701
+ interface GetCartAttributesProps {
702
+ profile?: any;
703
+ customer?: any;
704
+ cart?: NormalizedCart;
705
+ memberType?: string;
706
+ currentUrl?: string;
778
707
  }
779
708
  /**
780
- * Calculate available shipping methods based on product weight, member status, and available coupons
781
- *
782
- * @param options - Configuration options
783
- * @returns Shipping methods categorized by free/payment and overweight status
784
- *
785
- * @example
786
- * ```tsx
787
- * const { freeShippingMethods, paymentShippingMethods, nddOverweight, tddOverweight } = useShippingMethods({
788
- * variant,
789
- * plusMemberMetafields,
790
- * selectedPlusMemberMode,
791
- * })
792
- * ```
793
- */
794
- declare function useShippingMethods<TVariant extends {
795
- weight?: number;
796
- } = any>(options: UseShippingMethodsOptions<TVariant>): UseShippingMethodsResult;
797
-
798
- /**
799
- * Hook to replace cart plus member product
800
- *
801
- * When adding a monthly membership while an annual membership exists in cart,
802
- * the annual membership will be replaced and vice versa.
803
- *
804
- * @returns Handler function to replace conflicting membership products
805
- *
806
- * @example
807
- * ```tsx
808
- * const replaceCartPlusMember = useReplaceCartPlusMember()
809
- *
810
- * // Call before adding new membership product
811
- * await replaceCartPlusMember()
812
- * ```
813
- */
814
- declare const useReplaceCartPlusMember: () => () => Promise<void>;
815
-
816
- /**
817
- * Hook to get delivery discount codes from delivery data
818
- *
819
- * Extracts and returns the discount codes from the delivery custom data.
820
- *
821
- * @returns Array of discount codes or undefined
822
- *
823
- * @example
824
- * ```tsx
825
- * const deliveryCodes = usePlusMemberDeliveryCodes()
826
- * ```
709
+ * Get cart attributes (pure function version)
827
710
  */
828
- declare const usePlusMemberDeliveryCodes: () => (string | undefined)[];
829
-
830
- declare const usePlusMemberCheckoutCustomAttributes: ({ disableShipping, isPresaleContains, }: {
831
- disableShipping?: boolean;
832
- isPresaleContains?: boolean;
833
- }) => NormalizedAttribute[];
834
-
711
+ declare function getCartAttributes({ profile, customer, cart, memberType, currentUrl, }: GetCartAttributesProps): Array<{
712
+ key: string;
713
+ value: any;
714
+ }>;
835
715
  /**
836
- * useAutoRemovePlusMemberInCart Hook
837
- * 付费会员身份自动移除购物车中的会员产品
838
- * 年费会员删除月费会员产品,月费会员删除年费会员产品
716
+ * Hook to get cart attributes
839
717
  */
840
-
841
- interface UseAutoRemovePlusMemberInCartProps {
718
+ declare const useCartAttributes: ({ profile, customer, cart, memberType, }: {
842
719
  profile: any;
720
+ customer: any;
843
721
  cart?: NormalizedCart;
844
- memberSetting: PlusMemberSettingsMetafields;
845
- }
846
- /**
847
- * 自动移除购物车中的会员产品
848
- *
849
- * @param props - Hook 参数
850
- * @param props.memberSetting - Plus Member 配置
851
- * @param props.isMonthlyPlus - 用户是否是月费会员
852
- * @param props.isAnnualPlus - 用户是否是年费会员
853
- *
854
- * @example
855
- * ```tsx
856
- * const { profile } = useProfile()
857
- *
858
- * useAutoRemovePlusMemberInCart({
859
- * cart,
860
- * profile,
861
- * })
862
- * ```
863
- */
864
- declare function useAutoRemovePlusMemberInCart({ cart, profile, memberSetting, }: UseAutoRemovePlusMemberInCartProps): void;
722
+ memberType?: string;
723
+ }) => {
724
+ attributes: Array<{
725
+ key: string;
726
+ value: any;
727
+ }>;
728
+ };
729
+
730
+ declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
731
+ cart?: NormalizedCart;
732
+ cartItem: NormalizedLineItem;
733
+ config: {
734
+ handle: Record<string, {
735
+ min: number;
736
+ max: number;
737
+ }>;
738
+ sku: Record<string, {
739
+ min: number;
740
+ max: number;
741
+ }>;
742
+ };
743
+ }) => {
744
+ min: number;
745
+ max: number;
746
+ };
865
747
 
866
748
  /**
867
- * Has Plus Member In Cart
868
- * 判断购物车中是否包含年费会员或月费会员产品
749
+ * Hook to check if plus member products are in line items
750
+ * 判断加购的 line 中是否包含付费会员产品
869
751
  */
870
752
 
871
- interface HasPlusMemberInCartProps {
753
+ interface UseHasPlusMemberInLinesProps {
872
754
  /** Plus Member 配置 */
873
755
  memberSetting?: PlusMemberSettingsMetafields;
874
- /** 购物车数据 */
875
- cart?: NormalizedCart;
756
+ /** 加购的 line items */
757
+ lines: AddToCartLineItem[];
876
758
  }
877
- interface HasPlusMemberInCartResult {
878
- /** 购物车中是否有任何会员产品 */
759
+ interface HasPlusMemberInLinesResult {
760
+ /** 加购的 lines 中是否有任何会员产品 */
879
761
  hasPlusMember: boolean;
880
- /** 购物车中是否有月费会员产品 */
762
+ /** 加购的 lines 中是否有月费会员产品 */
881
763
  hasMonthlyPlus: boolean;
882
- /** 购物车中是否有年费会员产品 */
764
+ /** 加购的 lines 中是否有年费会员产品 */
883
765
  hasAnnualPlus: boolean;
884
766
  /** 月费会员产品的 line item */
885
- monthlyPlusItem?: {
886
- id: string;
887
- quantity: number;
888
- handle?: string;
889
- sku?: string;
890
- };
767
+ monthlyPlusLine?: AddToCartLineItem;
891
768
  /** 年费会员产品的 line item */
892
- annualPlusItem?: {
893
- id: string;
894
- quantity: number;
895
- handle?: string;
896
- sku?: string;
897
- };
769
+ annualPlusLine?: AddToCartLineItem;
898
770
  }
899
771
  /**
900
- * 判断购物车中是否包含年费会员或月费会员产品(纯函数版本)
772
+ * 判断加购的 line items 中是否包含付费会员产品(纯函数版本)
901
773
  *
902
774
  * @param props - 函数参数
903
775
  * @param props.memberSetting - Plus Member 配置
904
- * @param props.cart - 购物车数据
776
+ * @param props.lines - 加购的 line items
905
777
  * @returns 会员产品信息
906
778
  *
907
779
  * @example
@@ -910,27 +782,25 @@ interface HasPlusMemberInCartResult {
910
782
  * hasPlusMember,
911
783
  * hasMonthlyPlus,
912
784
  * hasAnnualPlus,
913
- * monthlyPlusItem,
914
- * annualPlusItem,
915
- * } = hasPlusMemberInCart({
785
+ * } = hasPlusMemberInLines({
916
786
  * memberSetting: plusMemberSettings,
917
- * cart: currentCart,
787
+ * lines: lineItems,
918
788
  * })
919
789
  *
920
790
  * if (hasPlusMember) {
921
- * console.log('购物车中有会员产品')
791
+ * console.log('加购的商品中包含会员产品')
922
792
  * }
923
793
  * ```
924
794
  */
925
- declare function hasPlusMemberInCart({ memberSetting, cart, }: HasPlusMemberInCartProps): HasPlusMemberInCartResult;
795
+ declare function hasPlusMemberInLines({ memberSetting, lines, }: UseHasPlusMemberInLinesProps): HasPlusMemberInLinesResult;
926
796
  /**
927
- * 判断购物车中是否包含年费会员或月费会员产品(Hook 版本)
797
+ * 判断加购的 line items 中是否包含付费会员产品(Hook 版本)
928
798
  *
929
- * 内部使用 hasPlusMemberInCart 纯函数,并通过 useMemo 优化性能
799
+ * 内部使用 hasPlusMemberInLines 纯函数,并通过 useMemo 优化性能
930
800
  *
931
801
  * @param props - Hook 参数
932
802
  * @param props.memberSetting - Plus Member 配置
933
- * @param props.cart - 购物车数据
803
+ * @param props.lines - 加购的 line items
934
804
  * @returns 会员产品信息
935
805
  *
936
806
  * @example
@@ -939,130 +809,22 @@ declare function hasPlusMemberInCart({ memberSetting, cart, }: HasPlusMemberInCa
939
809
  * hasPlusMember,
940
810
  * hasMonthlyPlus,
941
811
  * hasAnnualPlus,
942
- * monthlyPlusItem,
943
- * annualPlusItem,
944
- * } = useHasPlusMemberInCart({
812
+ * monthlyPlusLine,
813
+ * annualPlusLine,
814
+ * } = useHasPlusMemberInLines({
945
815
  * memberSetting: plusMemberSettings,
946
- * cart: currentCart,
816
+ * lines: lineItems,
947
817
  * })
948
818
  *
949
819
  * if (hasPlusMember) {
950
- * console.log('购物车中有会员产品')
820
+ * console.log('加购的商品中包含会员产品')
951
821
  * }
952
822
  * ```
953
823
  */
954
- declare function useHasPlusMemberInCart({ memberSetting, cart, }: HasPlusMemberInCartProps): HasPlusMemberInCartResult;
824
+ declare function useHasPlusMemberInLines({ memberSetting, lines, }: UseHasPlusMemberInLinesProps): HasPlusMemberInLinesResult;
955
825
 
956
826
  /**
957
- * 返回需要添加到购物车的 Plus Member 产品
958
- *
959
- * 该 hook 会根据用户选择的会员模式和购物车现有状态,
960
- * 返回需要添加的会员产品。如果不需要添加会员产品,则返回 undefined。
961
- *
962
- * @param props - Hook 参数
963
- * @param props.cart - 购物车数据
964
- * @returns Plus Member 产品对象或 undefined
965
- *
966
- * @example
967
- * ```tsx
968
- * const plusMemberVariant = usePlusMemberNeedAddToCart({
969
- * cart,
970
- * })
971
- *
972
- * ```
973
- */
974
- declare function usePlusMemberNeedAddToCart({ cart, profile, }: {
975
- cart: NormalizedCart;
976
- profile?: any;
977
- }): (_anker_in_shopify_sdk.NormalizedProductVariant & {
978
- product: _anker_in_shopify_sdk.NormalizedProduct | undefined;
979
- }) | undefined;
980
-
981
- interface UseAvailableDeliveryCouponResult {
982
- nddCoupon?: string;
983
- tddCoupon?: string;
984
- isLoading: boolean;
985
- }
986
- declare const useAvailableDeliveryCoupon: ({ profile, }: {
987
- profile?: any;
988
- }) => UseAvailableDeliveryCouponResult;
989
-
990
- interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile extends {
991
- isPlus?: boolean;
992
- } = any> {
993
- variant: TVariant;
994
- product: TProduct;
995
- memberSetting: PlusMemberSettingsMetafields;
996
- initialSelectedPlusMemberMode?: DeliveryPlusType;
997
- profile?: TProfile;
998
- }
999
- /**
1000
- * Plus Member Provider Component
1001
- *
1002
- * Provides Plus Member context and state management to child components.
1003
- *
1004
- * @param variant - Product variant
1005
- * @param product - Product
1006
- * @param metafields - Plus member settings from metafields
1007
- * @param initialSelectedPlusMemberMode - Initial selected mode (default: 'free')
1008
- * @param profile - User profile
1009
- * @param locale - Locale code
1010
- * @param children - Child components
1011
- *
1012
- * @example
1013
- * ```tsx
1014
- * <PlusMemberProvider
1015
- * variant={variant}
1016
- * product={product}
1017
- * memberSetting={memberSetting}
1018
- * profile={profile}
1019
- * >
1020
- * <YourComponent />
1021
- * </PlusMemberProvider>
1022
- * ```
1023
- */
1024
- declare const PlusMemberProvider: <TProduct = any, TVariant extends {
1025
- weight?: number;
1026
- } = any, TProfile extends {
1027
- isPlus?: boolean;
1028
- } = any>({ variant, product, memberSetting, initialSelectedPlusMemberMode, profile, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
1029
-
1030
- declare const getReferralAttributes: () => {
1031
- key: string;
1032
- value: any;
1033
- }[];
1034
- declare const useCartAttributes: ({ profile, customer, cart, memberSetting, }: {
1035
- profile: any;
1036
- customer: any;
1037
- cart?: NormalizedCart;
1038
- memberSetting?: PlusMemberSettingsMetafields;
1039
- }) => {
1040
- attributes: Array<{
1041
- key: string;
1042
- value: any;
1043
- }>;
1044
- };
1045
-
1046
- declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
1047
- cart?: NormalizedCart;
1048
- cartItem: NormalizedLineItem;
1049
- config: {
1050
- handle: Record<string, {
1051
- min: number;
1052
- max: number;
1053
- }>;
1054
- sku: Record<string, {
1055
- min: number;
1056
- max: number;
1057
- }>;
1058
- };
1059
- }) => {
1060
- min: number;
1061
- max: number;
1062
- };
1063
-
1064
- /**
1065
- * 更新购物车中各个 item 的折后价相关的属性
827
+ * 更新购物车中各个 item 的折后价相关的属性
1066
828
  */
1067
829
  declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, }: {
1068
830
  cart?: NormalizedCart;
@@ -1659,6 +1421,334 @@ interface UseSiteOptions extends SWRConfiguration<SiteInfo | undefined> {
1659
1421
  }
1660
1422
  declare function useSite(options?: UseSiteOptions): swr.SWRResponse<SiteInfo | undefined, any, SWRConfiguration<SiteInfo | undefined, any, ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SiteInfo | undefined>) | ((arg: readonly [any, ...unknown[]]) => swr__internal.FetcherResponse<SiteInfo | undefined>)> | undefined>;
1661
1423
 
1424
+ interface ShippingMethodsContext {
1425
+ freeShippingMethods: PlusMemberShippingMethodConfig[];
1426
+ paymentShippingMethods: PlusMemberShippingMethodConfig[];
1427
+ nddOverweight: boolean;
1428
+ tddOverweight: boolean;
1429
+ nddCoupon?: string;
1430
+ tddCoupon?: string;
1431
+ isLoadingCoupon: boolean;
1432
+ }
1433
+ interface PlusMemberContextValue<TProduct = any, TVariant = any, TProfile extends {
1434
+ isPlus?: boolean;
1435
+ } = any> {
1436
+ plusMemberMetafields: PlusMemberSettingsMetafields;
1437
+ selectedPlusMemberMode: DeliveryPlusType;
1438
+ setSelectedPlusMemberMode: (value: DeliveryPlusType) => void;
1439
+ selectedShippingMethod?: PlusMemberShippingMethodConfig;
1440
+ setSelectedShippingMethod: (value: PlusMemberShippingMethodConfig) => void;
1441
+ showMoreShippingMethod: boolean;
1442
+ setShowMoreShippingMethod: (value: boolean) => void;
1443
+ variant: TVariant;
1444
+ product: TProduct;
1445
+ shippingMethodsContext: ShippingMethodsContext;
1446
+ selectedPlusMemberVariant: SelectedPlusMemberVariant;
1447
+ showPlusMemberBenefit: boolean;
1448
+ setShowPlusMemberBenefit: (value: boolean) => void;
1449
+ profile?: TProfile;
1450
+ }
1451
+ declare const PlusMemberContext: React$1.Context<PlusMemberContextValue<any, any, any>>;
1452
+
1453
+ /**
1454
+ * Hook to access Plus Member Context
1455
+ */
1456
+ declare function usePlusMemberContext<TProfile extends {
1457
+ isPlus?: boolean;
1458
+ } = any>(): PlusMemberContextValue<any, any, any>;
1459
+
1460
+ /**
1461
+ * Hook to get Plus Member Product Variants (Monthly and Annual)
1462
+ */
1463
+
1464
+ interface UsePlusMemberVariantsOptions {
1465
+ /** Plus member metafields configuration */
1466
+ memberSetting: PlusMemberSettingsMetafields;
1467
+ }
1468
+ interface UsePlusMemberVariantsResult {
1469
+ monthlyVariant?: NormalizedProductVariant & {
1470
+ product: NormalizedProduct | undefined;
1471
+ };
1472
+ annualVariant?: NormalizedProductVariant & {
1473
+ product: NormalizedProduct | undefined;
1474
+ };
1475
+ }
1476
+ /**
1477
+ * Get Plus Member product variants (monthly and annual)
1478
+ *
1479
+ * @param options - Configuration options
1480
+ * @returns Monthly and annual variants
1481
+ *
1482
+ * @example
1483
+ * ```tsx
1484
+ * const { monthlyVariant, annualVariant } = usePlusMemberVariants({
1485
+ * plusMemberMetafields
1486
+ * })
1487
+ * ```
1488
+ */
1489
+ declare function usePlusMemberVariants({ memberSetting, }: UsePlusMemberVariantsOptions): UsePlusMemberVariantsResult;
1490
+
1491
+ /**
1492
+ * Hook to calculate available shipping methods based on product weight and member status
1493
+ */
1494
+
1495
+ interface UseShippingMethodsOptions<TVariant = any, TProfile extends {
1496
+ isPlus?: boolean;
1497
+ } = any> {
1498
+ /** Product variant with weight information */
1499
+ variant: TVariant;
1500
+ /** Plus member metafields configuration */
1501
+ plusMemberMetafields: PlusMemberSettingsMetafields;
1502
+ /** Selected plus member mode */
1503
+ selectedPlusMemberMode: DeliveryPlusType;
1504
+ profile?: TProfile;
1505
+ }
1506
+ interface UseShippingMethodsResult {
1507
+ freeShippingMethods: PlusMemberShippingMethodConfig[];
1508
+ paymentShippingMethods: PlusMemberShippingMethodConfig[];
1509
+ nddOverweight: boolean;
1510
+ tddOverweight: boolean;
1511
+ nddCoupon?: string;
1512
+ tddCoupon?: string;
1513
+ isLoadingCoupon: boolean;
1514
+ }
1515
+ /**
1516
+ * Calculate available shipping methods based on product weight, member status, and available coupons
1517
+ *
1518
+ * @param options - Configuration options
1519
+ * @returns Shipping methods categorized by free/payment and overweight status
1520
+ *
1521
+ * @example
1522
+ * ```tsx
1523
+ * const { freeShippingMethods, paymentShippingMethods, nddOverweight, tddOverweight } = useShippingMethods({
1524
+ * variant,
1525
+ * plusMemberMetafields,
1526
+ * selectedPlusMemberMode,
1527
+ * })
1528
+ * ```
1529
+ */
1530
+ declare function useShippingMethods<TVariant extends {
1531
+ weight?: number;
1532
+ } = any>(options: UseShippingMethodsOptions<TVariant>): UseShippingMethodsResult;
1533
+
1534
+ /**
1535
+ * Hook to replace cart plus member product
1536
+ *
1537
+ * When adding a monthly membership while an annual membership exists in cart,
1538
+ * the annual membership will be replaced and vice versa.
1539
+ *
1540
+ * @returns Handler function to replace conflicting membership products
1541
+ *
1542
+ * @example
1543
+ * ```tsx
1544
+ * const replaceCartPlusMember = useReplaceCartPlusMember()
1545
+ *
1546
+ * // Call before adding new membership product
1547
+ * await replaceCartPlusMember()
1548
+ * ```
1549
+ */
1550
+ declare const useReplaceCartPlusMember: () => () => Promise<void>;
1551
+
1552
+ declare const usePlusMemberCheckoutCustomAttributes: ({ disableShipping, isPresaleContains, }: {
1553
+ disableShipping?: boolean;
1554
+ isPresaleContains?: boolean;
1555
+ }) => NormalizedAttribute[];
1556
+
1557
+ /**
1558
+ * useAutoRemovePlusMemberInCart Hook
1559
+ * 付费会员身份自动移除购物车中的会员产品
1560
+ * 年费会员删除月费会员产品,月费会员删除年费会员产品
1561
+ */
1562
+
1563
+ interface UseAutoRemovePlusMemberInCartProps {
1564
+ profile: any;
1565
+ cart?: NormalizedCart;
1566
+ memberSetting: PlusMemberSettingsMetafields;
1567
+ }
1568
+ /**
1569
+ * 自动移除购物车中的会员产品
1570
+ *
1571
+ * @param props - Hook 参数
1572
+ * @param props.memberSetting - Plus Member 配置
1573
+ * @param props.isMonthlyPlus - 用户是否是月费会员
1574
+ * @param props.isAnnualPlus - 用户是否是年费会员
1575
+ *
1576
+ * @example
1577
+ * ```tsx
1578
+ * const { profile } = useProfile()
1579
+ *
1580
+ * useAutoRemovePlusMemberInCart({
1581
+ * cart,
1582
+ * profile,
1583
+ * })
1584
+ * ```
1585
+ */
1586
+ declare function useAutoRemovePlusMemberInCart({ cart, profile, memberSetting, }: UseAutoRemovePlusMemberInCartProps): void;
1587
+
1588
+ /**
1589
+ * Has Plus Member In Cart
1590
+ * 判断购物车中是否包含年费会员或月费会员产品
1591
+ */
1592
+
1593
+ interface HasPlusMemberInCartProps {
1594
+ /** Plus Member 配置 */
1595
+ memberSetting?: PlusMemberSettingsMetafields;
1596
+ /** 购物车数据 */
1597
+ cart?: NormalizedCart;
1598
+ }
1599
+ interface HasPlusMemberInCartResult {
1600
+ /** 购物车中是否有任何会员产品 */
1601
+ hasPlusMember: boolean;
1602
+ /** 购物车中是否有月费会员产品 */
1603
+ hasMonthlyPlus: boolean;
1604
+ /** 购物车中是否有年费会员产品 */
1605
+ hasAnnualPlus: boolean;
1606
+ /** 月费会员产品的 line item */
1607
+ monthlyPlusItem?: {
1608
+ id: string;
1609
+ quantity: number;
1610
+ handle?: string;
1611
+ sku?: string;
1612
+ };
1613
+ /** 年费会员产品的 line item */
1614
+ annualPlusItem?: {
1615
+ id: string;
1616
+ quantity: number;
1617
+ handle?: string;
1618
+ sku?: string;
1619
+ };
1620
+ }
1621
+ /**
1622
+ * 判断购物车中是否包含年费会员或月费会员产品(纯函数版本)
1623
+ *
1624
+ * @param props - 函数参数
1625
+ * @param props.memberSetting - Plus Member 配置
1626
+ * @param props.cart - 购物车数据
1627
+ * @returns 会员产品信息
1628
+ *
1629
+ * @example
1630
+ * ```tsx
1631
+ * const {
1632
+ * hasPlusMember,
1633
+ * hasMonthlyPlus,
1634
+ * hasAnnualPlus,
1635
+ * monthlyPlusItem,
1636
+ * annualPlusItem,
1637
+ * } = hasPlusMemberInCart({
1638
+ * memberSetting: plusMemberSettings,
1639
+ * cart: currentCart,
1640
+ * })
1641
+ *
1642
+ * if (hasPlusMember) {
1643
+ * console.log('购物车中有会员产品')
1644
+ * }
1645
+ * ```
1646
+ */
1647
+ declare function hasPlusMemberInCart({ memberSetting, cart, }: HasPlusMemberInCartProps): HasPlusMemberInCartResult;
1648
+ /**
1649
+ * 判断购物车中是否包含年费会员或月费会员产品(Hook 版本)
1650
+ *
1651
+ * 内部使用 hasPlusMemberInCart 纯函数,并通过 useMemo 优化性能
1652
+ *
1653
+ * @param props - Hook 参数
1654
+ * @param props.memberSetting - Plus Member 配置
1655
+ * @param props.cart - 购物车数据
1656
+ * @returns 会员产品信息
1657
+ *
1658
+ * @example
1659
+ * ```tsx
1660
+ * const {
1661
+ * hasPlusMember,
1662
+ * hasMonthlyPlus,
1663
+ * hasAnnualPlus,
1664
+ * monthlyPlusItem,
1665
+ * annualPlusItem,
1666
+ * } = useHasPlusMemberInCart({
1667
+ * memberSetting: plusMemberSettings,
1668
+ * cart: currentCart,
1669
+ * })
1670
+ *
1671
+ * if (hasPlusMember) {
1672
+ * console.log('购物车中有会员产品')
1673
+ * }
1674
+ * ```
1675
+ */
1676
+ declare function useHasPlusMemberInCart({ memberSetting, cart, }: HasPlusMemberInCartProps): HasPlusMemberInCartResult;
1677
+
1678
+ /**
1679
+ * 返回需要添加到购物车的 Plus Member 产品
1680
+ *
1681
+ * 该 hook 会根据用户选择的会员模式和购物车现有状态,
1682
+ * 返回需要添加的会员产品。如果不需要添加会员产品,则返回 undefined。
1683
+ *
1684
+ * @param props - Hook 参数
1685
+ * @param props.cart - 购物车数据
1686
+ * @returns Plus Member 产品对象或 undefined
1687
+ *
1688
+ * @example
1689
+ * ```tsx
1690
+ * const plusMemberVariant = usePlusMemberNeedAddToCart({
1691
+ * cart,
1692
+ * })
1693
+ *
1694
+ * ```
1695
+ */
1696
+ declare function usePlusMemberNeedAddToCart({ cart, profile, }: {
1697
+ cart: NormalizedCart;
1698
+ profile?: any;
1699
+ }): (_anker_in_shopify_sdk.NormalizedProductVariant & {
1700
+ product: _anker_in_shopify_sdk.NormalizedProduct | undefined;
1701
+ }) | undefined;
1702
+
1703
+ interface UseAvailableDeliveryCouponResult {
1704
+ nddCoupon?: string;
1705
+ tddCoupon?: string;
1706
+ isLoading: boolean;
1707
+ }
1708
+ declare const useAvailableDeliveryCoupon: ({ profile, }: {
1709
+ profile?: any;
1710
+ }) => UseAvailableDeliveryCouponResult;
1711
+
1712
+ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile extends {
1713
+ isPlus?: boolean;
1714
+ } = any> {
1715
+ variant: TVariant;
1716
+ product: TProduct;
1717
+ memberSetting: PlusMemberSettingsMetafields;
1718
+ initialSelectedPlusMemberMode?: DeliveryPlusType;
1719
+ profile?: TProfile;
1720
+ }
1721
+ /**
1722
+ * Plus Member Provider Component
1723
+ *
1724
+ * Provides Plus Member context and state management to child components.
1725
+ *
1726
+ * @param variant - Product variant
1727
+ * @param product - Product
1728
+ * @param metafields - Plus member settings from metafields
1729
+ * @param initialSelectedPlusMemberMode - Initial selected mode (default: 'free')
1730
+ * @param profile - User profile
1731
+ * @param locale - Locale code
1732
+ * @param children - Child components
1733
+ *
1734
+ * @example
1735
+ * ```tsx
1736
+ * <PlusMemberProvider
1737
+ * variant={variant}
1738
+ * product={product}
1739
+ * memberSetting={memberSetting}
1740
+ * profile={profile}
1741
+ * >
1742
+ * <YourComponent />
1743
+ * </PlusMemberProvider>
1744
+ * ```
1745
+ */
1746
+ declare const PlusMemberProvider: <TProduct = any, TVariant extends {
1747
+ weight?: number;
1748
+ } = any, TProfile extends {
1749
+ isPlus?: boolean;
1750
+ } = any>({ variant, product, memberSetting, initialSelectedPlusMemberMode, profile, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
1751
+
1662
1752
  /**
1663
1753
  * useIntersection Hook
1664
1754
  *
@@ -1894,4 +1984,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
1894
1984
  */
1895
1985
  declare function clearGeoLocationCache(cacheKey?: string): void;
1896
1986
 
1897
- 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, DeliveryPlusType, type DiscountLabel, type FormattedGift, type FunctionGiftResult, type GeoLocationData, type GiftProduct, type GiftProductItem, type GiftTier, type HasPlusMemberInCartProps, type HasPlusMemberInCartResult, type ImageMedia, type LocaleMapping, MAIN_PRODUCT_CODE, MEMBER_PRICE_ATTRIBUTE_KEY, 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, SelectedPlusMemberVariant, 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 UseAvailableDeliveryCouponResult, type UseBlogOptions, type UseBuyNowOptions, type UseCalcGiftsFromLinesOptions, type UseCalcGiftsFromLinesResult, type UseCollectionOptions, type UseCollectionsOptions, type UseExposureOptions, type UseGeoLocationOptions, type UseIntersectionOptions, type UsePlusMemberVariantsOptions, type UsePlusMemberVariantsResult, type UsePriceOptions, type UsePriceResult, type UseProductOptions, type UseProductsByHandlesOptions, type UseScriptAutoFreeGiftResult, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingMethodsResult, type UseSiteOptions, type UseUpdateCartAttributesOptions, type VariantItem, type VariantMedia, type 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 };
1987
+ 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, DeliveryPlusType, type DiscountLabel, type FormattedGift, type FunctionGiftResult, type GeoLocationData, type GetCartAttributesProps, type GiftProduct, type GiftProductItem, type GiftTier, type HasPlusMemberInCartProps, type HasPlusMemberInCartResult, type HasPlusMemberInLinesResult, type ImageMedia, type LocaleMapping, MAIN_PRODUCT_CODE, MEMBER_PRICE_ATTRIBUTE_KEY, 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, SelectedPlusMemberVariant, 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 UseAvailableDeliveryCouponResult, type UseBlogOptions, type UseBuyNowOptions, type UseCalcGiftsFromLinesOptions, type UseCalcGiftsFromLinesResult, type UseCollectionOptions, type UseCollectionsOptions, type UseExposureOptions, type UseGeoLocationOptions, type UseHasPlusMemberInLinesProps, type UseIntersectionOptions, type UsePlusMemberVariantsOptions, type UsePlusMemberVariantsResult, type UsePriceOptions, type UsePriceResult, type UseProductOptions, type UseProductsByHandlesOptions, type UseScriptAutoFreeGiftResult, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingMethodsResult, type UseSiteOptions, type UseUpdateCartAttributesOptions, type VariantItem, type VariantMedia, type VideoMedia, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getCartAttributes, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, getUserType, hasPlusMemberInCart, hasPlusMemberInLines, 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, useHasPlusMemberInLines, useIntersection, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberNeedAddToCart, usePlusMemberVariants, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethods, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdateVariantQuery, useVariant, useVariantMedia };