@anker-in/shopify-react 0.1.1-beta.41 → 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 +112 -168
- package/dist/hooks/index.d.ts +112 -168
- package/dist/hooks/index.js +122 -310
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +122 -307
- 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 +127 -311
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +127 -308
- 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 +54 -55
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +54 -55
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-y1Wa95P3.d.mts → types-CMMWxyUF.d.mts} +5 -10
- package/dist/{types-y1Wa95P3.d.ts → types-CMMWxyUF.d.ts} +5 -10
- package/package.json +3 -3
package/dist/hooks/index.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ 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
|
|
6
|
-
export { g as DeliveryCustomData, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, c as PlusMemberShippingMethodMetafields, S as ShippingMethodMode } from '../types-
|
|
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';
|
|
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';
|
|
@@ -455,15 +455,34 @@ interface UpdateCartAttributesInput {
|
|
|
455
455
|
value: string;
|
|
456
456
|
}>;
|
|
457
457
|
}
|
|
458
|
+
interface UseUpdateCartAttributesOptions {
|
|
459
|
+
/** Function to update cart state */
|
|
460
|
+
mutate: (cart: NormalizedCart | undefined) => void;
|
|
461
|
+
/** Metafield identifiers for variant and product */
|
|
462
|
+
metafieldIdentifiers?: {
|
|
463
|
+
variant: HasMetafieldsIdentifier[];
|
|
464
|
+
product: HasMetafieldsIdentifier[];
|
|
465
|
+
};
|
|
466
|
+
/** Disable the mutation */
|
|
467
|
+
disabled?: boolean;
|
|
468
|
+
/** SWR mutation configuration */
|
|
469
|
+
swrOptions?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'update-cart-attributes', UpdateCartAttributesInput>;
|
|
470
|
+
}
|
|
458
471
|
/**
|
|
459
472
|
* Hook for updating cart attributes (custom key-value pairs)
|
|
460
473
|
*
|
|
461
|
-
* @param options -
|
|
474
|
+
* @param options - Hook configuration options
|
|
462
475
|
* @returns SWR mutation with trigger function
|
|
463
476
|
*
|
|
464
477
|
* @example
|
|
465
478
|
* ```tsx
|
|
466
|
-
* const { trigger, isMutating } = useUpdateCartAttributes(
|
|
479
|
+
* const { trigger, isMutating } = useUpdateCartAttributes({
|
|
480
|
+
* mutate: mutateCart,
|
|
481
|
+
* metafieldIdentifiers: {
|
|
482
|
+
* variant: [...],
|
|
483
|
+
* product: [...]
|
|
484
|
+
* }
|
|
485
|
+
* })
|
|
467
486
|
*
|
|
468
487
|
* await trigger({
|
|
469
488
|
* attributes: [
|
|
@@ -473,10 +492,7 @@ interface UpdateCartAttributesInput {
|
|
|
473
492
|
* })
|
|
474
493
|
* ```
|
|
475
494
|
*/
|
|
476
|
-
declare function useUpdateCartAttributes(mutate:
|
|
477
|
-
variant: HasMetafieldsIdentifier[];
|
|
478
|
-
product: HasMetafieldsIdentifier[];
|
|
479
|
-
}, options?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'update-cart-attributes', UpdateCartAttributesInput>): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-attributes", UpdateCartAttributesInput>;
|
|
495
|
+
declare function useUpdateCartAttributes({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateCartAttributesOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-attributes", UpdateCartAttributesInput>;
|
|
480
496
|
|
|
481
497
|
interface BuyNowInput {
|
|
482
498
|
/** Metafield identifiers */
|
|
@@ -678,72 +694,78 @@ interface ShippingMethodsContext {
|
|
|
678
694
|
tddCoupon?: string;
|
|
679
695
|
isLoadingCoupon: boolean;
|
|
680
696
|
}
|
|
681
|
-
interface PlusMemberContextValue<TProduct = any, TVariant = any, TProfile
|
|
697
|
+
interface PlusMemberContextValue<TProduct = any, TVariant = any, TProfile extends {
|
|
698
|
+
isPlus?: boolean;
|
|
699
|
+
} = any> {
|
|
682
700
|
plusMemberMetafields: PlusMemberSettingsMetafields;
|
|
683
|
-
shopCommon?: Record<string, any>;
|
|
684
|
-
zipCode: string;
|
|
685
|
-
setZipCode: (value: string) => void;
|
|
686
|
-
allowNextDayDelivery: boolean;
|
|
687
|
-
setAllowNextDayDelivery: (value: boolean) => void;
|
|
688
|
-
allowThirdDayDelivery: boolean;
|
|
689
|
-
setAllowThirdDayDelivery: (value: boolean) => void;
|
|
690
701
|
selectedPlusMemberMode: DeliveryPlusType;
|
|
691
702
|
setSelectedPlusMemberMode: (value: DeliveryPlusType) => void;
|
|
692
|
-
showAreaCheckModal: boolean;
|
|
693
|
-
setShowAreaCheckModal: (value: boolean) => void;
|
|
694
703
|
selectedShippingMethod?: PlusMemberShippingMethodConfig;
|
|
695
704
|
setSelectedShippingMethod: (value: PlusMemberShippingMethodConfig) => void;
|
|
696
|
-
showTip: boolean;
|
|
697
|
-
setShowTip: (value: boolean) => void;
|
|
698
705
|
showMoreShippingMethod: boolean;
|
|
699
706
|
setShowMoreShippingMethod: (value: boolean) => void;
|
|
700
707
|
variant: TVariant;
|
|
701
708
|
product: TProduct;
|
|
702
709
|
shippingMethodsContext: ShippingMethodsContext;
|
|
703
|
-
|
|
704
|
-
plusMemberProducts: NormalizedProduct[];
|
|
710
|
+
selectedPlusMemberVariant: SelectedPlusMemberVariant;
|
|
705
711
|
showPlusMemberBenefit: boolean;
|
|
706
712
|
setShowPlusMemberBenefit: (value: boolean) => void;
|
|
707
|
-
deleteMarginBottom: boolean;
|
|
708
|
-
setDeleteMarginBottom: (value: boolean) => void;
|
|
709
713
|
profile?: TProfile;
|
|
710
|
-
locale?: string;
|
|
711
714
|
}
|
|
712
715
|
declare const PlusMemberContext: React$1.Context<PlusMemberContextValue<any, any, any>>;
|
|
713
716
|
|
|
714
717
|
/**
|
|
715
718
|
* Hook to access Plus Member Context
|
|
716
719
|
*/
|
|
717
|
-
declare function usePlusMemberContext<
|
|
720
|
+
declare function usePlusMemberContext<TProfile extends {
|
|
721
|
+
isPlus?: boolean;
|
|
722
|
+
} = any>(): PlusMemberContextValue<any, any, any>;
|
|
718
723
|
|
|
719
724
|
/**
|
|
720
|
-
* Hook to get Plus
|
|
725
|
+
* Hook to get Plus Member Product Variants (Monthly and Annual)
|
|
721
726
|
*/
|
|
722
|
-
declare function usePlusMonthlyProductVariant<TVariant = any>(): TVariant | undefined;
|
|
723
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
|
+
}
|
|
724
740
|
/**
|
|
725
|
-
*
|
|
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
|
+
* ```
|
|
726
752
|
*/
|
|
727
|
-
declare function
|
|
753
|
+
declare function usePlusMemberVariants({ memberSetting, }: UsePlusMemberVariantsOptions): UsePlusMemberVariantsResult;
|
|
728
754
|
|
|
729
755
|
/**
|
|
730
756
|
* Hook to calculate available shipping methods based on product weight and member status
|
|
731
757
|
*/
|
|
732
758
|
|
|
733
|
-
interface UseShippingMethodsOptions<TVariant = any
|
|
759
|
+
interface UseShippingMethodsOptions<TVariant = any, TProfile extends {
|
|
760
|
+
isPlus?: boolean;
|
|
761
|
+
} = any> {
|
|
734
762
|
/** Product variant with weight information */
|
|
735
763
|
variant: TVariant;
|
|
736
|
-
/** Whether next day delivery is allowed */
|
|
737
|
-
allowNextDayDelivery: boolean;
|
|
738
|
-
/** Whether third day delivery is allowed */
|
|
739
|
-
allowThirdDayDelivery: boolean;
|
|
740
764
|
/** Plus member metafields configuration */
|
|
741
765
|
plusMemberMetafields: PlusMemberSettingsMetafields;
|
|
742
766
|
/** Selected plus member mode */
|
|
743
767
|
selectedPlusMemberMode: DeliveryPlusType;
|
|
744
|
-
|
|
745
|
-
isPlus?: boolean;
|
|
746
|
-
profile?: any;
|
|
768
|
+
profile?: TProfile;
|
|
747
769
|
}
|
|
748
770
|
interface UseShippingMethodsResult {
|
|
749
771
|
freeShippingMethods: PlusMemberShippingMethodConfig[];
|
|
@@ -764,11 +786,8 @@ interface UseShippingMethodsResult {
|
|
|
764
786
|
* ```tsx
|
|
765
787
|
* const { freeShippingMethods, paymentShippingMethods, nddOverweight, tddOverweight } = useShippingMethods({
|
|
766
788
|
* variant,
|
|
767
|
-
* allowNextDayDelivery,
|
|
768
|
-
* allowThirdDayDelivery,
|
|
769
789
|
* plusMemberMetafields,
|
|
770
790
|
* selectedPlusMemberMode,
|
|
771
|
-
* isPlus: profile?.isPlus,
|
|
772
791
|
* })
|
|
773
792
|
* ```
|
|
774
793
|
*/
|
|
@@ -776,11 +795,6 @@ declare function useShippingMethods<TVariant extends {
|
|
|
776
795
|
weight?: number;
|
|
777
796
|
} = any>(options: UseShippingMethodsOptions<TVariant>): UseShippingMethodsResult;
|
|
778
797
|
|
|
779
|
-
/**
|
|
780
|
-
* Hook to check shipping method availability and automatically adjust selection
|
|
781
|
-
*/
|
|
782
|
-
declare function useShippingMethodAvailableCheck(): void;
|
|
783
|
-
|
|
784
798
|
/**
|
|
785
799
|
* Hook to replace cart plus member product
|
|
786
800
|
*
|
|
@@ -804,116 +818,18 @@ declare const useReplaceCartPlusMember: () => () => Promise<void>;
|
|
|
804
818
|
*
|
|
805
819
|
* Extracts and returns the discount codes from the delivery custom data.
|
|
806
820
|
*
|
|
807
|
-
* @param deliveryData - Delivery data containing custom attributes
|
|
808
821
|
* @returns Array of discount codes or undefined
|
|
809
822
|
*
|
|
810
823
|
* @example
|
|
811
824
|
* ```tsx
|
|
812
|
-
* const deliveryCodes = usePlusMemberDeliveryCodes(
|
|
813
|
-
* ```
|
|
814
|
-
*/
|
|
815
|
-
declare const usePlusMemberDeliveryCodes: ({ deliveryData, }: {
|
|
816
|
-
deliveryData?: DeliveryData;
|
|
817
|
-
}) => string[] | undefined;
|
|
818
|
-
|
|
819
|
-
interface UseUpdatePlusMemberDeliveryOptionsProps {
|
|
820
|
-
/** SWR mutation configuration */
|
|
821
|
-
options?: SWRMutationConfiguration<any, Error, 'update-cart-delivery-options', {
|
|
822
|
-
deliveryData: DeliveryData;
|
|
823
|
-
}>;
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* Hook to update cart delivery options based on plus member delivery data
|
|
827
|
-
*
|
|
828
|
-
* This hook extracts the selected delivery option from delivery custom data and
|
|
829
|
-
* maps it to the appropriate delivery option handle from the cart's deliveryGroups.
|
|
830
|
-
* It then triggers the update-cart-delivery-options mutation to apply the selection.
|
|
831
|
-
*
|
|
832
|
-
* The hook handles:
|
|
833
|
-
* - Extracting delivery option code from deliveryCustomData.selected_delivery_option
|
|
834
|
-
* - Finding the matching delivery option in cart.deliveryGroups
|
|
835
|
-
* - Triggering the cart update with the correct delivery option handle
|
|
836
|
-
*
|
|
837
|
-
* @param props - Hook properties
|
|
838
|
-
* @returns useSWRMutation result with trigger and loading state
|
|
839
|
-
*
|
|
840
|
-
* @example
|
|
841
|
-
* ```tsx
|
|
842
|
-
* const { trigger, isMutating } = useUpdatePlusMemberDeliveryOptions()
|
|
843
|
-
*
|
|
844
|
-
* // Trigger update with delivery data
|
|
845
|
-
* await trigger({ deliveryData })
|
|
846
|
-
* ```
|
|
847
|
-
*/
|
|
848
|
-
declare const useUpdatePlusMemberDeliveryOptions: ({ options, }?: UseUpdatePlusMemberDeliveryOptionsProps) => swr_mutation.SWRMutationResponse<any, Error, "update-cart-delivery-options", {
|
|
849
|
-
deliveryData: DeliveryData;
|
|
850
|
-
}>;
|
|
851
|
-
|
|
852
|
-
/**
|
|
853
|
-
* Hook to generate custom attributes for cart line items
|
|
854
|
-
*
|
|
855
|
-
* Creates custom attributes based on delivery data to be attached to line items.
|
|
856
|
-
*
|
|
857
|
-
* @param deliveryData - Delivery data containing custom attributes
|
|
858
|
-
* @returns Array of custom attributes for line items
|
|
859
|
-
*
|
|
860
|
-
* @example
|
|
861
|
-
* ```tsx
|
|
862
|
-
* const itemAttributes = usePlusMemberItemCustomAttributes({ deliveryData })
|
|
863
|
-
*
|
|
864
|
-
* // Use in addToCart
|
|
865
|
-
* await addToCart({
|
|
866
|
-
* lineItems: lineItems.map(item => ({
|
|
867
|
-
* ...item,
|
|
868
|
-
* customAttributes: [...(item.customAttributes || []), ...itemAttributes]
|
|
869
|
-
* }))
|
|
870
|
-
* })
|
|
825
|
+
* const deliveryCodes = usePlusMemberDeliveryCodes()
|
|
871
826
|
* ```
|
|
872
827
|
*/
|
|
873
|
-
declare const
|
|
874
|
-
deliveryData?: DeliveryData;
|
|
875
|
-
}) => NormalizedAttribute[];
|
|
828
|
+
declare const usePlusMemberDeliveryCodes: () => (string | undefined)[];
|
|
876
829
|
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
* Creates custom attributes based on delivery data, profile, and customer information
|
|
881
|
-
* to be attached to the checkout.
|
|
882
|
-
*
|
|
883
|
-
* Requires profile to be provided via PlusMemberContext.
|
|
884
|
-
*
|
|
885
|
-
* @param deliveryData - Delivery data containing custom attributes
|
|
886
|
-
* @param product - Product information (optional, for hiding shipping benefits check)
|
|
887
|
-
* @param variant - Variant information (optional, for presale and hiding shipping benefits check)
|
|
888
|
-
* @param isShowShippingBenefits - Function to check if shipping benefits should be shown (optional)
|
|
889
|
-
* @returns Array of custom attributes for checkout
|
|
890
|
-
*
|
|
891
|
-
* @example
|
|
892
|
-
* ```tsx
|
|
893
|
-
* const checkoutAttributes = usePlusMemberCheckoutCustomAttributes({
|
|
894
|
-
* deliveryData,
|
|
895
|
-
* product,
|
|
896
|
-
* variant,
|
|
897
|
-
* customer,
|
|
898
|
-
* isShowShippingBenefits
|
|
899
|
-
* })
|
|
900
|
-
*
|
|
901
|
-
* // Use in checkout
|
|
902
|
-
* await createCheckout({
|
|
903
|
-
* lineItems,
|
|
904
|
-
* customAttributes: checkoutAttributes
|
|
905
|
-
* })
|
|
906
|
-
* ```
|
|
907
|
-
*/
|
|
908
|
-
declare const usePlusMemberCheckoutCustomAttributes: <TProduct = any, TVariant = any>({ deliveryData, product, variant, isShowShippingBenefits, }: {
|
|
909
|
-
deliveryData?: DeliveryData;
|
|
910
|
-
product?: TProduct;
|
|
911
|
-
variant?: TVariant;
|
|
912
|
-
isShowShippingBenefits?: (args: {
|
|
913
|
-
variant?: TVariant;
|
|
914
|
-
product?: TProduct;
|
|
915
|
-
setting: any;
|
|
916
|
-
}) => boolean;
|
|
830
|
+
declare const usePlusMemberCheckoutCustomAttributes: ({ disableShipping, isPresaleContains, }: {
|
|
831
|
+
disableShipping?: boolean;
|
|
832
|
+
isPresaleContains?: boolean;
|
|
917
833
|
}) => NormalizedAttribute[];
|
|
918
834
|
|
|
919
835
|
/**
|
|
@@ -948,11 +864,11 @@ interface UseAutoRemovePlusMemberInCartProps {
|
|
|
948
864
|
declare function useAutoRemovePlusMemberInCart({ cart, profile, memberSetting, }: UseAutoRemovePlusMemberInCartProps): void;
|
|
949
865
|
|
|
950
866
|
/**
|
|
951
|
-
*
|
|
867
|
+
* Has Plus Member In Cart
|
|
952
868
|
* 判断购物车中是否包含年费会员或月费会员产品
|
|
953
869
|
*/
|
|
954
870
|
|
|
955
|
-
interface
|
|
871
|
+
interface HasPlusMemberInCartProps {
|
|
956
872
|
/** Plus Member 配置 */
|
|
957
873
|
memberSetting?: PlusMemberSettingsMetafields;
|
|
958
874
|
/** 购物车数据 */
|
|
@@ -981,10 +897,40 @@ interface HasPlusMemberInCartResult {
|
|
|
981
897
|
};
|
|
982
898
|
}
|
|
983
899
|
/**
|
|
984
|
-
*
|
|
900
|
+
* 判断购物车中是否包含年费会员或月费会员产品(纯函数版本)
|
|
901
|
+
*
|
|
902
|
+
* @param props - 函数参数
|
|
903
|
+
* @param props.memberSetting - Plus Member 配置
|
|
904
|
+
* @param props.cart - 购物车数据
|
|
905
|
+
* @returns 会员产品信息
|
|
906
|
+
*
|
|
907
|
+
* @example
|
|
908
|
+
* ```tsx
|
|
909
|
+
* const {
|
|
910
|
+
* hasPlusMember,
|
|
911
|
+
* hasMonthlyPlus,
|
|
912
|
+
* hasAnnualPlus,
|
|
913
|
+
* monthlyPlusItem,
|
|
914
|
+
* annualPlusItem,
|
|
915
|
+
* } = hasPlusMemberInCart({
|
|
916
|
+
* memberSetting: plusMemberSettings,
|
|
917
|
+
* cart: currentCart,
|
|
918
|
+
* })
|
|
919
|
+
*
|
|
920
|
+
* if (hasPlusMember) {
|
|
921
|
+
* console.log('购物车中有会员产品')
|
|
922
|
+
* }
|
|
923
|
+
* ```
|
|
924
|
+
*/
|
|
925
|
+
declare function hasPlusMemberInCart({ memberSetting, cart, }: HasPlusMemberInCartProps): HasPlusMemberInCartResult;
|
|
926
|
+
/**
|
|
927
|
+
* 判断购物车中是否包含年费会员或月费会员产品(Hook 版本)
|
|
928
|
+
*
|
|
929
|
+
* 内部使用 hasPlusMemberInCart 纯函数,并通过 useMemo 优化性能
|
|
985
930
|
*
|
|
986
931
|
* @param props - Hook 参数
|
|
987
|
-
* @param props.
|
|
932
|
+
* @param props.memberSetting - Plus Member 配置
|
|
933
|
+
* @param props.cart - 购物车数据
|
|
988
934
|
* @returns 会员产品信息
|
|
989
935
|
*
|
|
990
936
|
* @example
|
|
@@ -997,6 +943,7 @@ interface HasPlusMemberInCartResult {
|
|
|
997
943
|
* annualPlusItem,
|
|
998
944
|
* } = useHasPlusMemberInCart({
|
|
999
945
|
* memberSetting: plusMemberSettings,
|
|
946
|
+
* cart: currentCart,
|
|
1000
947
|
* })
|
|
1001
948
|
*
|
|
1002
949
|
* if (hasPlusMember) {
|
|
@@ -1004,7 +951,7 @@ interface HasPlusMemberInCartResult {
|
|
|
1004
951
|
* }
|
|
1005
952
|
* ```
|
|
1006
953
|
*/
|
|
1007
|
-
declare function useHasPlusMemberInCart({ memberSetting, cart, }:
|
|
954
|
+
declare function useHasPlusMemberInCart({ memberSetting, cart, }: HasPlusMemberInCartProps): HasPlusMemberInCartResult;
|
|
1008
955
|
|
|
1009
956
|
/**
|
|
1010
957
|
* 返回需要添加到购物车的 Plus Member 产品
|
|
@@ -1018,25 +965,18 @@ declare function useHasPlusMemberInCart({ memberSetting, cart, }: UseHasPlusMemb
|
|
|
1018
965
|
*
|
|
1019
966
|
* @example
|
|
1020
967
|
* ```tsx
|
|
1021
|
-
* const
|
|
968
|
+
* const plusMemberVariant = usePlusMemberNeedAddToCart({
|
|
1022
969
|
* cart,
|
|
1023
970
|
* })
|
|
1024
971
|
*
|
|
1025
|
-
* // plusMemberProduct 格式:
|
|
1026
|
-
* // {
|
|
1027
|
-
* // product: NormalizedProduct,
|
|
1028
|
-
* // variant: NormalizedProductVariant
|
|
1029
|
-
* // }
|
|
1030
|
-
* // 或 undefined (当不需要添加会员产品时)
|
|
1031
972
|
* ```
|
|
1032
973
|
*/
|
|
1033
974
|
declare function usePlusMemberNeedAddToCart({ cart, profile, }: {
|
|
1034
975
|
cart: NormalizedCart;
|
|
1035
976
|
profile?: any;
|
|
1036
|
-
}): {
|
|
1037
|
-
product: _anker_in_shopify_sdk.NormalizedProduct;
|
|
1038
|
-
|
|
1039
|
-
} | undefined;
|
|
977
|
+
}): (_anker_in_shopify_sdk.NormalizedProductVariant & {
|
|
978
|
+
product: _anker_in_shopify_sdk.NormalizedProduct | undefined;
|
|
979
|
+
}) | undefined;
|
|
1040
980
|
|
|
1041
981
|
interface UseAvailableDeliveryCouponResult {
|
|
1042
982
|
nddCoupon?: string;
|
|
@@ -1047,7 +987,9 @@ declare const useAvailableDeliveryCoupon: ({ profile, }: {
|
|
|
1047
987
|
profile?: any;
|
|
1048
988
|
}) => UseAvailableDeliveryCouponResult;
|
|
1049
989
|
|
|
1050
|
-
interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile
|
|
990
|
+
interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile extends {
|
|
991
|
+
isPlus?: boolean;
|
|
992
|
+
} = any> {
|
|
1051
993
|
variant: TVariant;
|
|
1052
994
|
product: TProduct;
|
|
1053
995
|
memberSetting: PlusMemberSettingsMetafields;
|
|
@@ -1079,7 +1021,9 @@ interface PlusMemberProviderProps<TProduct = any, TVariant = any, TProfile = any
|
|
|
1079
1021
|
* </PlusMemberProvider>
|
|
1080
1022
|
* ```
|
|
1081
1023
|
*/
|
|
1082
|
-
declare const PlusMemberProvider: <TProduct = any, TVariant
|
|
1024
|
+
declare const PlusMemberProvider: <TProduct = any, TVariant extends {
|
|
1025
|
+
weight?: number;
|
|
1026
|
+
} = any, TProfile extends {
|
|
1083
1027
|
isPlus?: boolean;
|
|
1084
1028
|
} = any>({ variant, product, memberSetting, initialSelectedPlusMemberMode, profile, children, }: PropsWithChildren<PlusMemberProviderProps<TProduct, TVariant, TProfile>>) => react_jsx_runtime.JSX.Element;
|
|
1085
1029
|
|
|
@@ -1950,4 +1894,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
1950
1894
|
*/
|
|
1951
1895
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
1952
1896
|
|
|
1953
|
-
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,
|
|
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 };
|