@anker-in/shopify-react 1.2.2-beta.8 → 1.3.0-beta.0
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 +47 -101
- package/dist/hooks/index.d.ts +47 -101
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +14 -28
- package/dist/provider/index.d.ts +14 -28
- package/dist/{types-DfR13pDe.d.mts → types-CMMWxyUF.d.mts} +11 -184
- package/dist/{types-DfR13pDe.d.ts → types-CMMWxyUF.d.ts} +11 -184
- package/package.json +5 -5
package/dist/hooks/index.d.mts
CHANGED
|
@@ -2,15 +2,15 @@ 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, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle, NormalizedAttribute } from '@anker-in/shopify-sdk';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
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
|
+
import Decimal from 'decimal.js';
|
|
7
8
|
import * as swr from 'swr';
|
|
8
9
|
import swr__default, { SWRConfiguration } from 'swr';
|
|
9
10
|
import * as swr__internal from 'swr/_internal';
|
|
10
11
|
import * as React$1 from 'react';
|
|
11
12
|
import { Dispatch, SetStateAction, PropsWithChildren, RefObject } from 'react';
|
|
12
13
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
13
|
-
import 'decimal.js';
|
|
14
14
|
|
|
15
15
|
interface CreateCartInput {
|
|
16
16
|
/** Lines to add to the cart */
|
|
@@ -498,63 +498,6 @@ interface UseUpdateCartAttributesOptions {
|
|
|
498
498
|
*/
|
|
499
499
|
declare function useUpdateCartAttributes({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateCartAttributesOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-attributes", UpdateCartAttributesInput>;
|
|
500
500
|
|
|
501
|
-
interface UpdateBuyerIdentityInput {
|
|
502
|
-
/** Cart ID (optional, will use cookie) */
|
|
503
|
-
cartId?: string;
|
|
504
|
-
/** Buyer identity information */
|
|
505
|
-
buyerIdentity: {
|
|
506
|
-
/** The email address of the buyer */
|
|
507
|
-
email?: string;
|
|
508
|
-
/** The phone number of the buyer */
|
|
509
|
-
phone?: string;
|
|
510
|
-
/** The country where the buyer is located */
|
|
511
|
-
countryCode?: string;
|
|
512
|
-
/** The access token used to identify the customer */
|
|
513
|
-
customerAccessToken?: string;
|
|
514
|
-
/** The company location of the buyer */
|
|
515
|
-
companyLocationId?: string;
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
interface UseUpdateBuyerIdentityOptions {
|
|
519
|
-
/** Function to update cart state */
|
|
520
|
-
mutate: (cart: NormalizedCart | undefined) => void;
|
|
521
|
-
/** Metafield identifiers for variant and product */
|
|
522
|
-
metafieldIdentifiers?: {
|
|
523
|
-
variant: HasMetafieldsIdentifier[];
|
|
524
|
-
product: HasMetafieldsIdentifier[];
|
|
525
|
-
};
|
|
526
|
-
/** Disable the mutation */
|
|
527
|
-
disabled?: boolean;
|
|
528
|
-
/** SWR mutation configuration */
|
|
529
|
-
swrOptions?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'update-buyer-identity', UpdateBuyerIdentityInput>;
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Hook for updating buyer identity in the cart
|
|
533
|
-
*
|
|
534
|
-
* @param options - Hook configuration options
|
|
535
|
-
* @returns SWR mutation with trigger function
|
|
536
|
-
*
|
|
537
|
-
* @example
|
|
538
|
-
* ```tsx
|
|
539
|
-
* const { trigger, isMutating } = useUpdateBuyerIdentity({
|
|
540
|
-
* mutate: mutateCart,
|
|
541
|
-
* metafieldIdentifiers: {
|
|
542
|
-
* variant: [...],
|
|
543
|
-
* product: [...]
|
|
544
|
-
* }
|
|
545
|
-
* })
|
|
546
|
-
*
|
|
547
|
-
* await trigger({
|
|
548
|
-
* buyerIdentity: {
|
|
549
|
-
* email: 'customer@example.com',
|
|
550
|
-
* countryCode: 'US',
|
|
551
|
-
* phone: '+1234567890'
|
|
552
|
-
* }
|
|
553
|
-
* })
|
|
554
|
-
* ```
|
|
555
|
-
*/
|
|
556
|
-
declare function useUpdateBuyerIdentity({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateBuyerIdentityOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-buyer-identity", UpdateBuyerIdentityInput>;
|
|
557
|
-
|
|
558
501
|
interface BuyNowInput {
|
|
559
502
|
/** Metafield identifiers */
|
|
560
503
|
metafieldIdentifiers?: {
|
|
@@ -629,6 +572,43 @@ declare function useBuyNow({ withTrack }?: UseBuyNowOptions, swrOptions?: SWRMut
|
|
|
629
572
|
*/
|
|
630
573
|
declare const useCalcAutoFreeGift: (cart: any, autoFreeGiftConfig: AutoFreeGiftConfig, customer: any, lines?: AddToCartLineItem[]) => FunctionGiftResult;
|
|
631
574
|
|
|
575
|
+
interface GiveawayProduct {
|
|
576
|
+
handle: string;
|
|
577
|
+
sku: string;
|
|
578
|
+
}
|
|
579
|
+
interface Breakpoint {
|
|
580
|
+
breakpoint: string;
|
|
581
|
+
giveawayProducts: GiveawayProduct[];
|
|
582
|
+
}
|
|
583
|
+
interface Campaign {
|
|
584
|
+
activityAvailableQuery?: string;
|
|
585
|
+
activityQroperty?: string;
|
|
586
|
+
breakpoints?: Array<{
|
|
587
|
+
breakpoint: string;
|
|
588
|
+
giveawayProducts: GiveawayProduct[];
|
|
589
|
+
}>;
|
|
590
|
+
includeTags?: string[];
|
|
591
|
+
useTotalAmount?: boolean;
|
|
592
|
+
requireLogin?: boolean;
|
|
593
|
+
}
|
|
594
|
+
interface UseScriptAutoFreeGiftResult {
|
|
595
|
+
involvedLines: NormalizedLineItem[];
|
|
596
|
+
reorder: (a: NormalizedLineItem, b: NormalizedLineItem) => number;
|
|
597
|
+
disableCodeRemove: boolean;
|
|
598
|
+
nextFreeGiftLevel: Breakpoint | null;
|
|
599
|
+
freeGiftLevel: Breakpoint | null;
|
|
600
|
+
involvedSubTotal: Decimal;
|
|
601
|
+
giftProductsResult?: NormalizedProduct[];
|
|
602
|
+
}
|
|
603
|
+
declare const useScriptAutoFreeGift: ({ campaign, _giveaway, cart, locale: providedLocale, lines, profile, }: {
|
|
604
|
+
campaign: Campaign | null;
|
|
605
|
+
_giveaway: string;
|
|
606
|
+
cart: NormalizedCart | undefined;
|
|
607
|
+
locale?: string;
|
|
608
|
+
lines?: AddToCartLineItem[];
|
|
609
|
+
profile?: any;
|
|
610
|
+
}) => UseScriptAutoFreeGiftResult;
|
|
611
|
+
|
|
632
612
|
interface UseCalcGiftsFromLinesOptions {
|
|
633
613
|
/** Lines to calculate gifts from (AddToCartLineItem format) */
|
|
634
614
|
lines: AddToCartLineItem[];
|
|
@@ -715,68 +695,36 @@ declare const getReferralAttributes: () => {
|
|
|
715
695
|
key: string;
|
|
716
696
|
value: any;
|
|
717
697
|
}[];
|
|
718
|
-
/**
|
|
719
|
-
* Detect operating system
|
|
720
|
-
*/
|
|
721
|
-
declare const getOperatingSystem: () => "Android" | "IOS" | "Unknown";
|
|
722
698
|
/**
|
|
723
699
|
* Get user type based on customer information
|
|
724
700
|
*/
|
|
725
701
|
declare const getUserType: (customer?: any) => string;
|
|
726
|
-
/**
|
|
727
|
-
* Get GA4 attributes (sync version)
|
|
728
|
-
*/
|
|
729
|
-
declare function getGA4Attributes(ga4Data?: {
|
|
730
|
-
clientId?: string;
|
|
731
|
-
sessionId?: string;
|
|
732
|
-
} | null): Array<{
|
|
733
|
-
key: string;
|
|
734
|
-
value: string;
|
|
735
|
-
}>;
|
|
736
|
-
/**
|
|
737
|
-
* Get GA4 attributes (async version)
|
|
738
|
-
* Fetches GA4 data and returns formatted attributes
|
|
739
|
-
*/
|
|
740
|
-
declare function getGA4AttributesAsync(): Promise<Array<{
|
|
741
|
-
key: string;
|
|
742
|
-
value: string;
|
|
743
|
-
}>>;
|
|
744
702
|
interface GetCartAttributesProps {
|
|
745
703
|
profile?: any;
|
|
746
704
|
customer?: any;
|
|
747
705
|
cart?: NormalizedCart;
|
|
748
706
|
memberType?: string;
|
|
749
707
|
currentUrl?: string;
|
|
750
|
-
appContext?: {
|
|
751
|
-
isInApp?: boolean;
|
|
752
|
-
appName?: string;
|
|
753
|
-
};
|
|
754
|
-
buyPath?: 'hasCart' | 'buyNow';
|
|
755
708
|
}
|
|
756
709
|
/**
|
|
757
|
-
* Get
|
|
710
|
+
* Get cart attributes (pure function version)
|
|
758
711
|
*/
|
|
759
|
-
declare function
|
|
712
|
+
declare function getCartAttributes({ profile, customer, cart, memberType, currentUrl, }: GetCartAttributesProps): Array<{
|
|
760
713
|
key: string;
|
|
761
|
-
value:
|
|
714
|
+
value: any;
|
|
762
715
|
}>;
|
|
763
716
|
/**
|
|
764
717
|
* Hook to get cart attributes
|
|
765
718
|
*/
|
|
766
|
-
declare const useCartAttributes: ({ profile, customer, cart, memberType,
|
|
719
|
+
declare const useCartAttributes: ({ profile, customer, cart, memberType, }: {
|
|
767
720
|
profile: any;
|
|
768
721
|
customer: any;
|
|
769
722
|
cart?: NormalizedCart;
|
|
770
723
|
memberType?: string;
|
|
771
|
-
appContext?: {
|
|
772
|
-
isInApp?: boolean;
|
|
773
|
-
appName?: string;
|
|
774
|
-
};
|
|
775
|
-
buyPath?: "hasCart" | "buyNow";
|
|
776
724
|
}) => {
|
|
777
725
|
attributes: Array<{
|
|
778
726
|
key: string;
|
|
779
|
-
value:
|
|
727
|
+
value: any;
|
|
780
728
|
}>;
|
|
781
729
|
};
|
|
782
730
|
|
|
@@ -801,7 +749,7 @@ declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
|
|
|
801
749
|
/**
|
|
802
750
|
* 更新购物车中各个 item 的折后价相关的属性
|
|
803
751
|
*/
|
|
804
|
-
declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers,
|
|
752
|
+
declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, }: {
|
|
805
753
|
cart?: NormalizedCart;
|
|
806
754
|
mutateCart: (cart: NormalizedCart | undefined) => void;
|
|
807
755
|
isCartLoading: boolean;
|
|
@@ -810,8 +758,6 @@ declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoad
|
|
|
810
758
|
variant: HasMetafieldsIdentifier[];
|
|
811
759
|
product: HasMetafieldsIdentifier[];
|
|
812
760
|
};
|
|
813
|
-
/** 是否禁用更新 */
|
|
814
|
-
disabled?: boolean;
|
|
815
761
|
}) => void;
|
|
816
762
|
|
|
817
763
|
declare const currencyCodeMapping: Record<string, string>;
|
|
@@ -2036,4 +1982,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
2036
1982
|
*/
|
|
2037
1983
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
2038
1984
|
|
|
2039
|
-
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
|
|
1985
|
+
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, 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 };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -2,15 +2,15 @@ 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, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle, NormalizedAttribute } from '@anker-in/shopify-sdk';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
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.js';
|
|
6
|
+
export { g as DeliveryCustomData, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, c as PlusMemberShippingMethodMetafields, S as ShippingMethodMode } from '../types-CMMWxyUF.js';
|
|
7
|
+
import Decimal from 'decimal.js';
|
|
7
8
|
import * as swr from 'swr';
|
|
8
9
|
import swr__default, { SWRConfiguration } from 'swr';
|
|
9
10
|
import * as swr__internal from 'swr/_internal';
|
|
10
11
|
import * as React$1 from 'react';
|
|
11
12
|
import { Dispatch, SetStateAction, PropsWithChildren, RefObject } from 'react';
|
|
12
13
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
13
|
-
import 'decimal.js';
|
|
14
14
|
|
|
15
15
|
interface CreateCartInput {
|
|
16
16
|
/** Lines to add to the cart */
|
|
@@ -498,63 +498,6 @@ interface UseUpdateCartAttributesOptions {
|
|
|
498
498
|
*/
|
|
499
499
|
declare function useUpdateCartAttributes({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateCartAttributesOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-attributes", UpdateCartAttributesInput>;
|
|
500
500
|
|
|
501
|
-
interface UpdateBuyerIdentityInput {
|
|
502
|
-
/** Cart ID (optional, will use cookie) */
|
|
503
|
-
cartId?: string;
|
|
504
|
-
/** Buyer identity information */
|
|
505
|
-
buyerIdentity: {
|
|
506
|
-
/** The email address of the buyer */
|
|
507
|
-
email?: string;
|
|
508
|
-
/** The phone number of the buyer */
|
|
509
|
-
phone?: string;
|
|
510
|
-
/** The country where the buyer is located */
|
|
511
|
-
countryCode?: string;
|
|
512
|
-
/** The access token used to identify the customer */
|
|
513
|
-
customerAccessToken?: string;
|
|
514
|
-
/** The company location of the buyer */
|
|
515
|
-
companyLocationId?: string;
|
|
516
|
-
};
|
|
517
|
-
}
|
|
518
|
-
interface UseUpdateBuyerIdentityOptions {
|
|
519
|
-
/** Function to update cart state */
|
|
520
|
-
mutate: (cart: NormalizedCart | undefined) => void;
|
|
521
|
-
/** Metafield identifiers for variant and product */
|
|
522
|
-
metafieldIdentifiers?: {
|
|
523
|
-
variant: HasMetafieldsIdentifier[];
|
|
524
|
-
product: HasMetafieldsIdentifier[];
|
|
525
|
-
};
|
|
526
|
-
/** Disable the mutation */
|
|
527
|
-
disabled?: boolean;
|
|
528
|
-
/** SWR mutation configuration */
|
|
529
|
-
swrOptions?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'update-buyer-identity', UpdateBuyerIdentityInput>;
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* Hook for updating buyer identity in the cart
|
|
533
|
-
*
|
|
534
|
-
* @param options - Hook configuration options
|
|
535
|
-
* @returns SWR mutation with trigger function
|
|
536
|
-
*
|
|
537
|
-
* @example
|
|
538
|
-
* ```tsx
|
|
539
|
-
* const { trigger, isMutating } = useUpdateBuyerIdentity({
|
|
540
|
-
* mutate: mutateCart,
|
|
541
|
-
* metafieldIdentifiers: {
|
|
542
|
-
* variant: [...],
|
|
543
|
-
* product: [...]
|
|
544
|
-
* }
|
|
545
|
-
* })
|
|
546
|
-
*
|
|
547
|
-
* await trigger({
|
|
548
|
-
* buyerIdentity: {
|
|
549
|
-
* email: 'customer@example.com',
|
|
550
|
-
* countryCode: 'US',
|
|
551
|
-
* phone: '+1234567890'
|
|
552
|
-
* }
|
|
553
|
-
* })
|
|
554
|
-
* ```
|
|
555
|
-
*/
|
|
556
|
-
declare function useUpdateBuyerIdentity({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateBuyerIdentityOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-buyer-identity", UpdateBuyerIdentityInput>;
|
|
557
|
-
|
|
558
501
|
interface BuyNowInput {
|
|
559
502
|
/** Metafield identifiers */
|
|
560
503
|
metafieldIdentifiers?: {
|
|
@@ -629,6 +572,43 @@ declare function useBuyNow({ withTrack }?: UseBuyNowOptions, swrOptions?: SWRMut
|
|
|
629
572
|
*/
|
|
630
573
|
declare const useCalcAutoFreeGift: (cart: any, autoFreeGiftConfig: AutoFreeGiftConfig, customer: any, lines?: AddToCartLineItem[]) => FunctionGiftResult;
|
|
631
574
|
|
|
575
|
+
interface GiveawayProduct {
|
|
576
|
+
handle: string;
|
|
577
|
+
sku: string;
|
|
578
|
+
}
|
|
579
|
+
interface Breakpoint {
|
|
580
|
+
breakpoint: string;
|
|
581
|
+
giveawayProducts: GiveawayProduct[];
|
|
582
|
+
}
|
|
583
|
+
interface Campaign {
|
|
584
|
+
activityAvailableQuery?: string;
|
|
585
|
+
activityQroperty?: string;
|
|
586
|
+
breakpoints?: Array<{
|
|
587
|
+
breakpoint: string;
|
|
588
|
+
giveawayProducts: GiveawayProduct[];
|
|
589
|
+
}>;
|
|
590
|
+
includeTags?: string[];
|
|
591
|
+
useTotalAmount?: boolean;
|
|
592
|
+
requireLogin?: boolean;
|
|
593
|
+
}
|
|
594
|
+
interface UseScriptAutoFreeGiftResult {
|
|
595
|
+
involvedLines: NormalizedLineItem[];
|
|
596
|
+
reorder: (a: NormalizedLineItem, b: NormalizedLineItem) => number;
|
|
597
|
+
disableCodeRemove: boolean;
|
|
598
|
+
nextFreeGiftLevel: Breakpoint | null;
|
|
599
|
+
freeGiftLevel: Breakpoint | null;
|
|
600
|
+
involvedSubTotal: Decimal;
|
|
601
|
+
giftProductsResult?: NormalizedProduct[];
|
|
602
|
+
}
|
|
603
|
+
declare const useScriptAutoFreeGift: ({ campaign, _giveaway, cart, locale: providedLocale, lines, profile, }: {
|
|
604
|
+
campaign: Campaign | null;
|
|
605
|
+
_giveaway: string;
|
|
606
|
+
cart: NormalizedCart | undefined;
|
|
607
|
+
locale?: string;
|
|
608
|
+
lines?: AddToCartLineItem[];
|
|
609
|
+
profile?: any;
|
|
610
|
+
}) => UseScriptAutoFreeGiftResult;
|
|
611
|
+
|
|
632
612
|
interface UseCalcGiftsFromLinesOptions {
|
|
633
613
|
/** Lines to calculate gifts from (AddToCartLineItem format) */
|
|
634
614
|
lines: AddToCartLineItem[];
|
|
@@ -715,68 +695,36 @@ declare const getReferralAttributes: () => {
|
|
|
715
695
|
key: string;
|
|
716
696
|
value: any;
|
|
717
697
|
}[];
|
|
718
|
-
/**
|
|
719
|
-
* Detect operating system
|
|
720
|
-
*/
|
|
721
|
-
declare const getOperatingSystem: () => "Android" | "IOS" | "Unknown";
|
|
722
698
|
/**
|
|
723
699
|
* Get user type based on customer information
|
|
724
700
|
*/
|
|
725
701
|
declare const getUserType: (customer?: any) => string;
|
|
726
|
-
/**
|
|
727
|
-
* Get GA4 attributes (sync version)
|
|
728
|
-
*/
|
|
729
|
-
declare function getGA4Attributes(ga4Data?: {
|
|
730
|
-
clientId?: string;
|
|
731
|
-
sessionId?: string;
|
|
732
|
-
} | null): Array<{
|
|
733
|
-
key: string;
|
|
734
|
-
value: string;
|
|
735
|
-
}>;
|
|
736
|
-
/**
|
|
737
|
-
* Get GA4 attributes (async version)
|
|
738
|
-
* Fetches GA4 data and returns formatted attributes
|
|
739
|
-
*/
|
|
740
|
-
declare function getGA4AttributesAsync(): Promise<Array<{
|
|
741
|
-
key: string;
|
|
742
|
-
value: string;
|
|
743
|
-
}>>;
|
|
744
702
|
interface GetCartAttributesProps {
|
|
745
703
|
profile?: any;
|
|
746
704
|
customer?: any;
|
|
747
705
|
cart?: NormalizedCart;
|
|
748
706
|
memberType?: string;
|
|
749
707
|
currentUrl?: string;
|
|
750
|
-
appContext?: {
|
|
751
|
-
isInApp?: boolean;
|
|
752
|
-
appName?: string;
|
|
753
|
-
};
|
|
754
|
-
buyPath?: 'hasCart' | 'buyNow';
|
|
755
708
|
}
|
|
756
709
|
/**
|
|
757
|
-
* Get
|
|
710
|
+
* Get cart attributes (pure function version)
|
|
758
711
|
*/
|
|
759
|
-
declare function
|
|
712
|
+
declare function getCartAttributes({ profile, customer, cart, memberType, currentUrl, }: GetCartAttributesProps): Array<{
|
|
760
713
|
key: string;
|
|
761
|
-
value:
|
|
714
|
+
value: any;
|
|
762
715
|
}>;
|
|
763
716
|
/**
|
|
764
717
|
* Hook to get cart attributes
|
|
765
718
|
*/
|
|
766
|
-
declare const useCartAttributes: ({ profile, customer, cart, memberType,
|
|
719
|
+
declare const useCartAttributes: ({ profile, customer, cart, memberType, }: {
|
|
767
720
|
profile: any;
|
|
768
721
|
customer: any;
|
|
769
722
|
cart?: NormalizedCart;
|
|
770
723
|
memberType?: string;
|
|
771
|
-
appContext?: {
|
|
772
|
-
isInApp?: boolean;
|
|
773
|
-
appName?: string;
|
|
774
|
-
};
|
|
775
|
-
buyPath?: "hasCart" | "buyNow";
|
|
776
724
|
}) => {
|
|
777
725
|
attributes: Array<{
|
|
778
726
|
key: string;
|
|
779
|
-
value:
|
|
727
|
+
value: any;
|
|
780
728
|
}>;
|
|
781
729
|
};
|
|
782
730
|
|
|
@@ -801,7 +749,7 @@ declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
|
|
|
801
749
|
/**
|
|
802
750
|
* 更新购物车中各个 item 的折后价相关的属性
|
|
803
751
|
*/
|
|
804
|
-
declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers,
|
|
752
|
+
declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, }: {
|
|
805
753
|
cart?: NormalizedCart;
|
|
806
754
|
mutateCart: (cart: NormalizedCart | undefined) => void;
|
|
807
755
|
isCartLoading: boolean;
|
|
@@ -810,8 +758,6 @@ declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoad
|
|
|
810
758
|
variant: HasMetafieldsIdentifier[];
|
|
811
759
|
product: HasMetafieldsIdentifier[];
|
|
812
760
|
};
|
|
813
|
-
/** 是否禁用更新 */
|
|
814
|
-
disabled?: boolean;
|
|
815
761
|
}) => void;
|
|
816
762
|
|
|
817
763
|
declare const currencyCodeMapping: Record<string, string>;
|
|
@@ -2036,4 +1982,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
2036
1982
|
*/
|
|
2037
1983
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
2038
1984
|
|
|
2039
|
-
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
|
|
1985
|
+
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, 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 };
|