@anker-in/shopify-react 1.0.1 → 1.0.3
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 +59 -1
- package/dist/hooks/index.d.ts +59 -1
- package/dist/hooks/index.js +34 -12
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +35 -14
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +34 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -14
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.js +2 -3
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +2 -3
- package/dist/provider/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/hooks/index.d.mts
CHANGED
|
@@ -67,6 +67,7 @@ interface AddCartLinesInput {
|
|
|
67
67
|
cartId?: string;
|
|
68
68
|
/** Lines to add */
|
|
69
69
|
lines: CartLineInput[];
|
|
70
|
+
updateCookie?: boolean;
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
73
|
* Hook for adding lines to cart
|
|
@@ -497,6 +498,63 @@ interface UseUpdateCartAttributesOptions {
|
|
|
497
498
|
*/
|
|
498
499
|
declare function useUpdateCartAttributes({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateCartAttributesOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-attributes", UpdateCartAttributesInput>;
|
|
499
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
|
+
|
|
500
558
|
interface BuyNowInput {
|
|
501
559
|
/** Metafield identifiers */
|
|
502
560
|
metafieldIdentifiers?: {
|
|
@@ -1981,4 +2039,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
1981
2039
|
*/
|
|
1982
2040
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
1983
2041
|
|
|
1984
|
-
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 };
|
|
2042
|
+
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, type 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, 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, useUpdateBuyerIdentity, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdateVariantQuery, useVariant, useVariantMedia };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ interface AddCartLinesInput {
|
|
|
67
67
|
cartId?: string;
|
|
68
68
|
/** Lines to add */
|
|
69
69
|
lines: CartLineInput[];
|
|
70
|
+
updateCookie?: boolean;
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
73
|
* Hook for adding lines to cart
|
|
@@ -497,6 +498,63 @@ interface UseUpdateCartAttributesOptions {
|
|
|
497
498
|
*/
|
|
498
499
|
declare function useUpdateCartAttributes({ mutate, metafieldIdentifiers, disabled, swrOptions, }: UseUpdateCartAttributesOptions): swr_mutation.SWRMutationResponse<NormalizedCart | undefined, Error, "update-cart-attributes", UpdateCartAttributesInput>;
|
|
499
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
|
+
|
|
500
558
|
interface BuyNowInput {
|
|
501
559
|
/** Metafield identifiers */
|
|
502
560
|
metafieldIdentifiers?: {
|
|
@@ -1981,4 +2039,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
1981
2039
|
*/
|
|
1982
2040
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
1983
2041
|
|
|
1984
|
-
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 };
|
|
2042
|
+
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, type 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, 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, useUpdateBuyerIdentity, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdateVariantQuery, useVariant, useVariantMedia };
|
package/dist/hooks/index.js
CHANGED
|
@@ -130,8 +130,6 @@ function createMockCartFromLines(lines, existingCart) {
|
|
|
130
130
|
const currency = lines[0]?.variant?.price?.currencyCode;
|
|
131
131
|
return {
|
|
132
132
|
id: existingCart?.id || "temp-cart-id",
|
|
133
|
-
customerId: existingCart?.customerId,
|
|
134
|
-
email: existingCart?.email,
|
|
135
133
|
createdAt: existingCart?.createdAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
136
134
|
currency: existingCart?.currency || { code: currency },
|
|
137
135
|
taxesIncluded: existingCart?.taxesIncluded,
|
|
@@ -146,7 +144,8 @@ function createMockCartFromLines(lines, existingCart) {
|
|
|
146
144
|
discountAllocations: [],
|
|
147
145
|
url: existingCart?.url || "",
|
|
148
146
|
ready: true,
|
|
149
|
-
customAttributes: existingCart?.customAttributes
|
|
147
|
+
customAttributes: existingCart?.customAttributes,
|
|
148
|
+
buyerIdentity: existingCart?.buyerIdentity
|
|
150
149
|
};
|
|
151
150
|
}
|
|
152
151
|
|
|
@@ -722,14 +721,15 @@ function useAddCartLines(options) {
|
|
|
722
721
|
const { mutateCart, metafieldIdentifiers } = useCartContext();
|
|
723
722
|
const addLines = react.useCallback(
|
|
724
723
|
async (_key, { arg }) => {
|
|
725
|
-
const { cartId, lines } = arg;
|
|
724
|
+
const { cartId, lines, updateCookie = true } = arg;
|
|
726
725
|
const id = cartId || cartCookieAdapter?.getCartId(locale);
|
|
727
726
|
let updatedCart;
|
|
728
727
|
if (!id) {
|
|
729
728
|
updatedCart = await shopifySdk.createCart(client, {
|
|
730
729
|
lines,
|
|
731
730
|
metafieldIdentifiers,
|
|
732
|
-
cookieAdapter: cartCookieAdapter
|
|
731
|
+
cookieAdapter: cartCookieAdapter,
|
|
732
|
+
updateCookie
|
|
733
733
|
});
|
|
734
734
|
} else {
|
|
735
735
|
updatedCart = await shopifySdk.addCartLines(client, {
|
|
@@ -891,14 +891,10 @@ function useApplyCartCodes(options) {
|
|
|
891
891
|
const { mutateCart, cart, metafieldIdentifiers } = useCartContext();
|
|
892
892
|
const applyCodes = react.useCallback(
|
|
893
893
|
async (_key, { arg }) => {
|
|
894
|
-
const { cartId
|
|
894
|
+
const { cartId, discountCodes, replaceExistingCodes } = arg;
|
|
895
895
|
if (!discountCodes?.length) {
|
|
896
896
|
throw new Error("Invalid input used for this operation: Miss discountCode");
|
|
897
897
|
}
|
|
898
|
-
const cartId = providedCartId || cart?.id;
|
|
899
|
-
if (!cartId) {
|
|
900
|
-
return void 0;
|
|
901
|
-
}
|
|
902
898
|
const updatedCart = await shopifySdk.updateCartCodes(client, {
|
|
903
899
|
cartId,
|
|
904
900
|
discountCodes: replaceExistingCodes ? discountCodes : [
|
|
@@ -928,8 +924,7 @@ function useRemoveCartCodes(options) {
|
|
|
928
924
|
const { mutateCart, cart, metafieldIdentifiers } = useCartContext();
|
|
929
925
|
const removeCodes = react.useCallback(
|
|
930
926
|
async (_key, { arg }) => {
|
|
931
|
-
const { cartId
|
|
932
|
-
const cartId = providedCartId || cart?.id;
|
|
927
|
+
const { cartId, discountCodes } = arg;
|
|
933
928
|
const codes = cart?.discountCodes?.filter((code) => !!code.applicable) || [];
|
|
934
929
|
const leftCodes = codes.filter((code) => discountCodes?.length ? !discountCodes.includes(code.code) : code.code).map((code) => code.code);
|
|
935
930
|
const updatedCart = await shopifySdk.updateCartCodes(client, {
|
|
@@ -2226,6 +2221,32 @@ function useUpdateCartAttributes({
|
|
|
2226
2221
|
);
|
|
2227
2222
|
return useSWRMutation__default.default("update-cart-attributes", updateAttributes, swrOptions);
|
|
2228
2223
|
}
|
|
2224
|
+
function useUpdateBuyerIdentity({
|
|
2225
|
+
mutate,
|
|
2226
|
+
metafieldIdentifiers,
|
|
2227
|
+
disabled = false,
|
|
2228
|
+
swrOptions
|
|
2229
|
+
}) {
|
|
2230
|
+
const { client, locale, cartCookieAdapter } = useShopify();
|
|
2231
|
+
const updateIdentity = react.useCallback(
|
|
2232
|
+
async (_key, { arg }) => {
|
|
2233
|
+
if (disabled) {
|
|
2234
|
+
return void 0;
|
|
2235
|
+
}
|
|
2236
|
+
const updatedCart = await shopifySdk.updateBuyerIdentity(client, {
|
|
2237
|
+
...arg,
|
|
2238
|
+
metafieldIdentifiers,
|
|
2239
|
+
cookieAdapter: cartCookieAdapter
|
|
2240
|
+
});
|
|
2241
|
+
if (updatedCart) {
|
|
2242
|
+
mutate(updatedCart);
|
|
2243
|
+
}
|
|
2244
|
+
return updatedCart;
|
|
2245
|
+
},
|
|
2246
|
+
[client, locale, cartCookieAdapter, mutate, metafieldIdentifiers, disabled]
|
|
2247
|
+
);
|
|
2248
|
+
return useSWRMutation__default.default("update-buyer-identity", updateIdentity, swrOptions);
|
|
2249
|
+
}
|
|
2229
2250
|
function useBuyNow({ withTrack = true } = {}, swrOptions) {
|
|
2230
2251
|
const { client, config, locale, cartCookieAdapter, userAdapter } = useShopify();
|
|
2231
2252
|
const { profile, customer, memberSetting } = useCartContext();
|
|
@@ -3171,6 +3192,7 @@ exports.useSearch = useSearch;
|
|
|
3171
3192
|
exports.useSelectedOptions = useSelectedOptions;
|
|
3172
3193
|
exports.useShippingMethods = useShippingMethods;
|
|
3173
3194
|
exports.useSite = useSite;
|
|
3195
|
+
exports.useUpdateBuyerIdentity = useUpdateBuyerIdentity;
|
|
3174
3196
|
exports.useUpdateCartAttributes = useUpdateCartAttributes;
|
|
3175
3197
|
exports.useUpdateCartLines = useUpdateCartLines;
|
|
3176
3198
|
exports.useUpdateLineCodeAmountAttributes = useUpdateLineCodeAmountAttributes;
|