@anker-in/shopify-react 1.3.0-beta.0 → 1.3.0-beta.2
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 +93 -56
- package/dist/hooks/index.d.ts +93 -56
- package/dist/hooks/index.js +139 -139
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +140 -140
- 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 +25 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -4
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +30 -14
- package/dist/provider/index.d.ts +30 -14
- package/dist/provider/index.js +138 -6
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +139 -7
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-CMMWxyUF.d.mts → types-CM5QrlnE.d.mts} +185 -15
- package/dist/{types-CMMWxyUF.d.ts → types-CM5QrlnE.d.ts} +185 -15
- package/package.json +3 -3
package/dist/hooks/index.d.mts
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
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
|
-
import { CartLineInput, NormalizedCart, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, UpdateCartLinesOptions, HasMetafieldsIdentifier, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle, NormalizedAttribute } from '@anker-in/shopify-sdk';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
7
|
-
import Decimal from 'decimal.js';
|
|
4
|
+
import { CartLineInput, BuyerIdentityInput, NormalizedCart, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, UpdateCartLinesOptions, HasMetafieldsIdentifier, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle, NormalizedAttribute } from '@anker-in/shopify-sdk';
|
|
5
|
+
import { h as UseAddToCartOptions, g as AddToCartInput, A as AddToCartLineItem, G as GtmParams, C as BuyNowTrackConfig, e as UseScriptAutoFreeGiftResult, m as PlusMemberShippingMethodConfig, n as PlusMemberSettingsMetafields, D as DeliveryPlusType, o as SelectedPlusMemberVariant } from '../types-CM5QrlnE.mjs';
|
|
6
|
+
export { p as DeliveryCustomData, P as PLUS_MEMBER_TYPE, j as PlusMemberMode, l as PlusMemberShippingMethodMetafields, S as ScriptAutoFreeGiftConfig, k as ShippingMethodMode, U as UseAutoRemoveFreeGiftsOptions, a as UseAutoRemoveFreeGiftsResult, d as isAnyGift, c as isBuyGetGift, i as isFunctionGift, b as isScriptGift, u as useAutoRemoveFreeGifts, f as useScriptAutoFreeGift } from '../types-CM5QrlnE.mjs';
|
|
8
7
|
import * as swr from 'swr';
|
|
9
8
|
import swr__default, { SWRConfiguration } from 'swr';
|
|
10
9
|
import * as swr__internal from 'swr/_internal';
|
|
11
10
|
import * as React$1 from 'react';
|
|
12
11
|
import { Dispatch, SetStateAction, PropsWithChildren, RefObject } from 'react';
|
|
13
12
|
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 */
|
|
17
17
|
lines?: CartLineInput[];
|
|
18
18
|
/** Buyer identity for cart creation */
|
|
19
|
-
buyerIdentity?:
|
|
20
|
-
email?: string;
|
|
21
|
-
countryCode?: string;
|
|
22
|
-
};
|
|
19
|
+
buyerIdentity?: BuyerIdentityInput;
|
|
23
20
|
/** Discount codes */
|
|
24
21
|
discountCodes?: string[];
|
|
25
22
|
/** Custom attributes */
|
|
@@ -498,6 +495,52 @@ interface UseUpdateCartAttributesOptions {
|
|
|
498
495
|
*/
|
|
499
496
|
declare function useUpdateCartAttributes({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateCartAttributesOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-attributes", UpdateCartAttributesInput>;
|
|
500
497
|
|
|
498
|
+
interface UpdateBuyerIdentityInput {
|
|
499
|
+
/** Cart ID (optional, will use cookie) */
|
|
500
|
+
cartId?: string;
|
|
501
|
+
/** Buyer identity information */
|
|
502
|
+
buyerIdentity: BuyerIdentityInput;
|
|
503
|
+
}
|
|
504
|
+
interface UseUpdateBuyerIdentityOptions {
|
|
505
|
+
/** Function to update cart state */
|
|
506
|
+
mutate: (cart: NormalizedCart | undefined) => void;
|
|
507
|
+
/** Metafield identifiers for variant and product */
|
|
508
|
+
metafieldIdentifiers?: {
|
|
509
|
+
variant: HasMetafieldsIdentifier[];
|
|
510
|
+
product: HasMetafieldsIdentifier[];
|
|
511
|
+
};
|
|
512
|
+
/** Disable the mutation */
|
|
513
|
+
disabled?: boolean;
|
|
514
|
+
/** SWR mutation configuration */
|
|
515
|
+
swrOptions?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'update-buyer-identity', UpdateBuyerIdentityInput>;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Hook for updating buyer identity in the cart
|
|
519
|
+
*
|
|
520
|
+
* @param options - Hook configuration options
|
|
521
|
+
* @returns SWR mutation with trigger function
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```tsx
|
|
525
|
+
* const { trigger, isMutating } = useUpdateBuyerIdentity({
|
|
526
|
+
* mutate: mutateCart,
|
|
527
|
+
* metafieldIdentifiers: {
|
|
528
|
+
* variant: [...],
|
|
529
|
+
* product: [...]
|
|
530
|
+
* }
|
|
531
|
+
* })
|
|
532
|
+
*
|
|
533
|
+
* await trigger({
|
|
534
|
+
* buyerIdentity: {
|
|
535
|
+
* email: 'customer@example.com',
|
|
536
|
+
* countryCode: 'US',
|
|
537
|
+
* phone: '+1234567890'
|
|
538
|
+
* }
|
|
539
|
+
* })
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
declare function useUpdateBuyerIdentity({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateBuyerIdentityOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-buyer-identity", UpdateBuyerIdentityInput>;
|
|
543
|
+
|
|
501
544
|
interface BuyNowInput {
|
|
502
545
|
/** Metafield identifiers */
|
|
503
546
|
metafieldIdentifiers?: {
|
|
@@ -514,10 +557,7 @@ interface BuyNowInput {
|
|
|
514
557
|
value: string;
|
|
515
558
|
}>;
|
|
516
559
|
/** Buyer identity */
|
|
517
|
-
buyerIdentity?:
|
|
518
|
-
email?: string;
|
|
519
|
-
countryCode?: string;
|
|
520
|
-
};
|
|
560
|
+
buyerIdentity?: BuyerIdentityInput;
|
|
521
561
|
/** GTM tracking parameters */
|
|
522
562
|
gtmParams?: Omit<GtmParams, 'brand'>;
|
|
523
563
|
/** Facebook Pixel tracking configuration */
|
|
@@ -572,43 +612,6 @@ declare function useBuyNow({ withTrack }?: UseBuyNowOptions, swrOptions?: SWRMut
|
|
|
572
612
|
*/
|
|
573
613
|
declare const useCalcAutoFreeGift: (cart: any, autoFreeGiftConfig: AutoFreeGiftConfig, customer: any, lines?: AddToCartLineItem[]) => FunctionGiftResult;
|
|
574
614
|
|
|
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
|
-
|
|
612
615
|
interface UseCalcGiftsFromLinesOptions {
|
|
613
616
|
/** Lines to calculate gifts from (AddToCartLineItem format) */
|
|
614
617
|
lines: AddToCartLineItem[];
|
|
@@ -695,36 +698,68 @@ declare const getReferralAttributes: () => {
|
|
|
695
698
|
key: string;
|
|
696
699
|
value: any;
|
|
697
700
|
}[];
|
|
701
|
+
/**
|
|
702
|
+
* Detect operating system
|
|
703
|
+
*/
|
|
704
|
+
declare const getOperatingSystem: () => "Android" | "IOS" | "Unknown";
|
|
698
705
|
/**
|
|
699
706
|
* Get user type based on customer information
|
|
700
707
|
*/
|
|
701
708
|
declare const getUserType: (customer?: any) => string;
|
|
709
|
+
/**
|
|
710
|
+
* Get GA4 attributes (sync version)
|
|
711
|
+
*/
|
|
712
|
+
declare function getGA4Attributes(ga4Data?: {
|
|
713
|
+
clientId?: string;
|
|
714
|
+
sessionId?: string;
|
|
715
|
+
} | null): Array<{
|
|
716
|
+
key: string;
|
|
717
|
+
value: string;
|
|
718
|
+
}>;
|
|
719
|
+
/**
|
|
720
|
+
* Get GA4 attributes (async version)
|
|
721
|
+
* Fetches GA4 data and returns formatted attributes
|
|
722
|
+
*/
|
|
723
|
+
declare function getGA4AttributesAsync(): Promise<Array<{
|
|
724
|
+
key: string;
|
|
725
|
+
value: string;
|
|
726
|
+
}>>;
|
|
702
727
|
interface GetCartAttributesProps {
|
|
703
728
|
profile?: any;
|
|
704
729
|
customer?: any;
|
|
705
730
|
cart?: NormalizedCart;
|
|
706
731
|
memberType?: string;
|
|
707
732
|
currentUrl?: string;
|
|
733
|
+
appContext?: {
|
|
734
|
+
isInApp?: boolean;
|
|
735
|
+
appName?: string;
|
|
736
|
+
};
|
|
737
|
+
buyPath?: 'hasCart' | 'buyNow';
|
|
708
738
|
}
|
|
709
739
|
/**
|
|
710
|
-
* Get cart attributes (pure function version)
|
|
740
|
+
* Get basic cart attributes (pure function version)
|
|
711
741
|
*/
|
|
712
|
-
declare function
|
|
742
|
+
declare function getCartBasicAttributes({ profile, customer, cart, memberType, currentUrl, appContext, buyPath, }: GetCartAttributesProps): Array<{
|
|
713
743
|
key: string;
|
|
714
|
-
value:
|
|
744
|
+
value: string;
|
|
715
745
|
}>;
|
|
716
746
|
/**
|
|
717
747
|
* Hook to get cart attributes
|
|
718
748
|
*/
|
|
719
|
-
declare const useCartAttributes: ({ profile, customer, cart, memberType, }: {
|
|
749
|
+
declare const useCartAttributes: ({ profile, customer, cart, memberType, appContext, buyPath, }: {
|
|
720
750
|
profile: any;
|
|
721
751
|
customer: any;
|
|
722
752
|
cart?: NormalizedCart;
|
|
723
753
|
memberType?: string;
|
|
754
|
+
appContext?: {
|
|
755
|
+
isInApp?: boolean;
|
|
756
|
+
appName?: string;
|
|
757
|
+
};
|
|
758
|
+
buyPath?: "hasCart" | "buyNow";
|
|
724
759
|
}) => {
|
|
725
760
|
attributes: Array<{
|
|
726
761
|
key: string;
|
|
727
|
-
value:
|
|
762
|
+
value: string;
|
|
728
763
|
}>;
|
|
729
764
|
};
|
|
730
765
|
|
|
@@ -749,7 +784,7 @@ declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
|
|
|
749
784
|
/**
|
|
750
785
|
* 更新购物车中各个 item 的折后价相关的属性
|
|
751
786
|
*/
|
|
752
|
-
declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, }: {
|
|
787
|
+
declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, disabled, }: {
|
|
753
788
|
cart?: NormalizedCart;
|
|
754
789
|
mutateCart: (cart: NormalizedCart | undefined) => void;
|
|
755
790
|
isCartLoading: boolean;
|
|
@@ -758,6 +793,8 @@ declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoad
|
|
|
758
793
|
variant: HasMetafieldsIdentifier[];
|
|
759
794
|
product: HasMetafieldsIdentifier[];
|
|
760
795
|
};
|
|
796
|
+
/** 是否禁用更新 */
|
|
797
|
+
disabled?: boolean;
|
|
761
798
|
}) => void;
|
|
762
799
|
|
|
763
800
|
declare const currencyCodeMapping: Record<string, string>;
|
|
@@ -1982,4 +2019,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
1982
2019
|
*/
|
|
1983
2020
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
1984
2021
|
|
|
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,
|
|
2022
|
+
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 UpdateBuyerIdentityInput, 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, UseScriptAutoFreeGiftResult, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingMethodsResult, type UseSiteOptions, type UseUpdateBuyerIdentityOptions, type UseUpdateCartAttributesOptions, type VariantItem, type VariantMedia, type VideoMedia, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getCartBasicAttributes, getDiscountEnvAttributeValue, getGA4Attributes, getGA4AttributesAsync, getMatchedMainProductSubTotal, getOperatingSystem, 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, useSearch, useSelectedOptions, useShippingMethods, useSite, useUpdateBuyerIdentity, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdateVariantQuery, useVariant, useVariantMedia };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
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
|
-
import { CartLineInput, NormalizedCart, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, UpdateCartLinesOptions, HasMetafieldsIdentifier, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle, NormalizedAttribute } from '@anker-in/shopify-sdk';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
7
|
-
import Decimal from 'decimal.js';
|
|
4
|
+
import { CartLineInput, BuyerIdentityInput, NormalizedCart, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, UpdateCartLinesOptions, HasMetafieldsIdentifier, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle, NormalizedAttribute } from '@anker-in/shopify-sdk';
|
|
5
|
+
import { h as UseAddToCartOptions, g as AddToCartInput, A as AddToCartLineItem, G as GtmParams, C as BuyNowTrackConfig, e as UseScriptAutoFreeGiftResult, m as PlusMemberShippingMethodConfig, n as PlusMemberSettingsMetafields, D as DeliveryPlusType, o as SelectedPlusMemberVariant } from '../types-CM5QrlnE.js';
|
|
6
|
+
export { p as DeliveryCustomData, P as PLUS_MEMBER_TYPE, j as PlusMemberMode, l as PlusMemberShippingMethodMetafields, S as ScriptAutoFreeGiftConfig, k as ShippingMethodMode, U as UseAutoRemoveFreeGiftsOptions, a as UseAutoRemoveFreeGiftsResult, d as isAnyGift, c as isBuyGetGift, i as isFunctionGift, b as isScriptGift, u as useAutoRemoveFreeGifts, f as useScriptAutoFreeGift } from '../types-CM5QrlnE.js';
|
|
8
7
|
import * as swr from 'swr';
|
|
9
8
|
import swr__default, { SWRConfiguration } from 'swr';
|
|
10
9
|
import * as swr__internal from 'swr/_internal';
|
|
11
10
|
import * as React$1 from 'react';
|
|
12
11
|
import { Dispatch, SetStateAction, PropsWithChildren, RefObject } from 'react';
|
|
13
12
|
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 */
|
|
17
17
|
lines?: CartLineInput[];
|
|
18
18
|
/** Buyer identity for cart creation */
|
|
19
|
-
buyerIdentity?:
|
|
20
|
-
email?: string;
|
|
21
|
-
countryCode?: string;
|
|
22
|
-
};
|
|
19
|
+
buyerIdentity?: BuyerIdentityInput;
|
|
23
20
|
/** Discount codes */
|
|
24
21
|
discountCodes?: string[];
|
|
25
22
|
/** Custom attributes */
|
|
@@ -498,6 +495,52 @@ interface UseUpdateCartAttributesOptions {
|
|
|
498
495
|
*/
|
|
499
496
|
declare function useUpdateCartAttributes({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateCartAttributesOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-attributes", UpdateCartAttributesInput>;
|
|
500
497
|
|
|
498
|
+
interface UpdateBuyerIdentityInput {
|
|
499
|
+
/** Cart ID (optional, will use cookie) */
|
|
500
|
+
cartId?: string;
|
|
501
|
+
/** Buyer identity information */
|
|
502
|
+
buyerIdentity: BuyerIdentityInput;
|
|
503
|
+
}
|
|
504
|
+
interface UseUpdateBuyerIdentityOptions {
|
|
505
|
+
/** Function to update cart state */
|
|
506
|
+
mutate: (cart: NormalizedCart | undefined) => void;
|
|
507
|
+
/** Metafield identifiers for variant and product */
|
|
508
|
+
metafieldIdentifiers?: {
|
|
509
|
+
variant: HasMetafieldsIdentifier[];
|
|
510
|
+
product: HasMetafieldsIdentifier[];
|
|
511
|
+
};
|
|
512
|
+
/** Disable the mutation */
|
|
513
|
+
disabled?: boolean;
|
|
514
|
+
/** SWR mutation configuration */
|
|
515
|
+
swrOptions?: SWRMutationConfiguration<NormalizedCart | undefined, Error, 'update-buyer-identity', UpdateBuyerIdentityInput>;
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Hook for updating buyer identity in the cart
|
|
519
|
+
*
|
|
520
|
+
* @param options - Hook configuration options
|
|
521
|
+
* @returns SWR mutation with trigger function
|
|
522
|
+
*
|
|
523
|
+
* @example
|
|
524
|
+
* ```tsx
|
|
525
|
+
* const { trigger, isMutating } = useUpdateBuyerIdentity({
|
|
526
|
+
* mutate: mutateCart,
|
|
527
|
+
* metafieldIdentifiers: {
|
|
528
|
+
* variant: [...],
|
|
529
|
+
* product: [...]
|
|
530
|
+
* }
|
|
531
|
+
* })
|
|
532
|
+
*
|
|
533
|
+
* await trigger({
|
|
534
|
+
* buyerIdentity: {
|
|
535
|
+
* email: 'customer@example.com',
|
|
536
|
+
* countryCode: 'US',
|
|
537
|
+
* phone: '+1234567890'
|
|
538
|
+
* }
|
|
539
|
+
* })
|
|
540
|
+
* ```
|
|
541
|
+
*/
|
|
542
|
+
declare function useUpdateBuyerIdentity({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateBuyerIdentityOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-buyer-identity", UpdateBuyerIdentityInput>;
|
|
543
|
+
|
|
501
544
|
interface BuyNowInput {
|
|
502
545
|
/** Metafield identifiers */
|
|
503
546
|
metafieldIdentifiers?: {
|
|
@@ -514,10 +557,7 @@ interface BuyNowInput {
|
|
|
514
557
|
value: string;
|
|
515
558
|
}>;
|
|
516
559
|
/** Buyer identity */
|
|
517
|
-
buyerIdentity?:
|
|
518
|
-
email?: string;
|
|
519
|
-
countryCode?: string;
|
|
520
|
-
};
|
|
560
|
+
buyerIdentity?: BuyerIdentityInput;
|
|
521
561
|
/** GTM tracking parameters */
|
|
522
562
|
gtmParams?: Omit<GtmParams, 'brand'>;
|
|
523
563
|
/** Facebook Pixel tracking configuration */
|
|
@@ -572,43 +612,6 @@ declare function useBuyNow({ withTrack }?: UseBuyNowOptions, swrOptions?: SWRMut
|
|
|
572
612
|
*/
|
|
573
613
|
declare const useCalcAutoFreeGift: (cart: any, autoFreeGiftConfig: AutoFreeGiftConfig, customer: any, lines?: AddToCartLineItem[]) => FunctionGiftResult;
|
|
574
614
|
|
|
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
|
-
|
|
612
615
|
interface UseCalcGiftsFromLinesOptions {
|
|
613
616
|
/** Lines to calculate gifts from (AddToCartLineItem format) */
|
|
614
617
|
lines: AddToCartLineItem[];
|
|
@@ -695,36 +698,68 @@ declare const getReferralAttributes: () => {
|
|
|
695
698
|
key: string;
|
|
696
699
|
value: any;
|
|
697
700
|
}[];
|
|
701
|
+
/**
|
|
702
|
+
* Detect operating system
|
|
703
|
+
*/
|
|
704
|
+
declare const getOperatingSystem: () => "Android" | "IOS" | "Unknown";
|
|
698
705
|
/**
|
|
699
706
|
* Get user type based on customer information
|
|
700
707
|
*/
|
|
701
708
|
declare const getUserType: (customer?: any) => string;
|
|
709
|
+
/**
|
|
710
|
+
* Get GA4 attributes (sync version)
|
|
711
|
+
*/
|
|
712
|
+
declare function getGA4Attributes(ga4Data?: {
|
|
713
|
+
clientId?: string;
|
|
714
|
+
sessionId?: string;
|
|
715
|
+
} | null): Array<{
|
|
716
|
+
key: string;
|
|
717
|
+
value: string;
|
|
718
|
+
}>;
|
|
719
|
+
/**
|
|
720
|
+
* Get GA4 attributes (async version)
|
|
721
|
+
* Fetches GA4 data and returns formatted attributes
|
|
722
|
+
*/
|
|
723
|
+
declare function getGA4AttributesAsync(): Promise<Array<{
|
|
724
|
+
key: string;
|
|
725
|
+
value: string;
|
|
726
|
+
}>>;
|
|
702
727
|
interface GetCartAttributesProps {
|
|
703
728
|
profile?: any;
|
|
704
729
|
customer?: any;
|
|
705
730
|
cart?: NormalizedCart;
|
|
706
731
|
memberType?: string;
|
|
707
732
|
currentUrl?: string;
|
|
733
|
+
appContext?: {
|
|
734
|
+
isInApp?: boolean;
|
|
735
|
+
appName?: string;
|
|
736
|
+
};
|
|
737
|
+
buyPath?: 'hasCart' | 'buyNow';
|
|
708
738
|
}
|
|
709
739
|
/**
|
|
710
|
-
* Get cart attributes (pure function version)
|
|
740
|
+
* Get basic cart attributes (pure function version)
|
|
711
741
|
*/
|
|
712
|
-
declare function
|
|
742
|
+
declare function getCartBasicAttributes({ profile, customer, cart, memberType, currentUrl, appContext, buyPath, }: GetCartAttributesProps): Array<{
|
|
713
743
|
key: string;
|
|
714
|
-
value:
|
|
744
|
+
value: string;
|
|
715
745
|
}>;
|
|
716
746
|
/**
|
|
717
747
|
* Hook to get cart attributes
|
|
718
748
|
*/
|
|
719
|
-
declare const useCartAttributes: ({ profile, customer, cart, memberType, }: {
|
|
749
|
+
declare const useCartAttributes: ({ profile, customer, cart, memberType, appContext, buyPath, }: {
|
|
720
750
|
profile: any;
|
|
721
751
|
customer: any;
|
|
722
752
|
cart?: NormalizedCart;
|
|
723
753
|
memberType?: string;
|
|
754
|
+
appContext?: {
|
|
755
|
+
isInApp?: boolean;
|
|
756
|
+
appName?: string;
|
|
757
|
+
};
|
|
758
|
+
buyPath?: "hasCart" | "buyNow";
|
|
724
759
|
}) => {
|
|
725
760
|
attributes: Array<{
|
|
726
761
|
key: string;
|
|
727
|
-
value:
|
|
762
|
+
value: string;
|
|
728
763
|
}>;
|
|
729
764
|
};
|
|
730
765
|
|
|
@@ -749,7 +784,7 @@ declare const useCartItemQuantityLimit: ({ cart, cartItem, config, }: {
|
|
|
749
784
|
/**
|
|
750
785
|
* 更新购物车中各个 item 的折后价相关的属性
|
|
751
786
|
*/
|
|
752
|
-
declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, }: {
|
|
787
|
+
declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoading, setLoadingState, metafieldIdentifiers, disabled, }: {
|
|
753
788
|
cart?: NormalizedCart;
|
|
754
789
|
mutateCart: (cart: NormalizedCart | undefined) => void;
|
|
755
790
|
isCartLoading: boolean;
|
|
@@ -758,6 +793,8 @@ declare const useUpdateLineCodeAmountAttributes: ({ cart, mutateCart, isCartLoad
|
|
|
758
793
|
variant: HasMetafieldsIdentifier[];
|
|
759
794
|
product: HasMetafieldsIdentifier[];
|
|
760
795
|
};
|
|
796
|
+
/** 是否禁用更新 */
|
|
797
|
+
disabled?: boolean;
|
|
761
798
|
}) => void;
|
|
762
799
|
|
|
763
800
|
declare const currencyCodeMapping: Record<string, string>;
|
|
@@ -1982,4 +2019,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
1982
2019
|
*/
|
|
1983
2020
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
1984
2021
|
|
|
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,
|
|
2022
|
+
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 UpdateBuyerIdentityInput, 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, UseScriptAutoFreeGiftResult, type UseSearchOptions, type UseShippingMethodsOptions, type UseShippingMethodsResult, type UseSiteOptions, type UseUpdateBuyerIdentityOptions, type UseUpdateCartAttributesOptions, type VariantItem, type VariantMedia, type VideoMedia, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getCartBasicAttributes, getDiscountEnvAttributeValue, getGA4Attributes, getGA4AttributesAsync, getMatchedMainProductSubTotal, getOperatingSystem, 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, useSearch, useSelectedOptions, useShippingMethods, useSite, useUpdateBuyerIdentity, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdateVariantQuery, useVariant, useVariantMedia };
|