@anker-in/shopify-react 0.1.1-beta.8 → 0.1.1-beta.9
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 +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +63 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +64 -3
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/{index-AJXjqRBR.d.ts → index-DMLI1Lh0.d.ts} +36 -3
- package/dist/{index-B9HdNo3a.d.mts → index-DyExTsmO.d.mts} +36 -3
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +63 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -3
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.js +1 -1
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +1 -1
- package/dist/provider/index.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
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 as CartLineInput$1, NormalizedCart, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, Attribute as Attribute$1, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
|
|
4
|
+
import { CartLineInput as CartLineInput$1, NormalizedCart, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, CartSelectedDeliveryOptionInput, Attribute as Attribute$1, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
|
|
5
5
|
import { A as AddToCartLineItem, G as GtmParams, B as BuyNowTrackConfig, d as PlusMemberShippingMethodConfig, e as PlusMemberSettingsMetafields, D as DeliveryPlusType, f as SelectedPlusMemberProduct, i as DeliveryData } from './types-CICUnw0v.js';
|
|
6
6
|
import Decimal from 'decimal.js';
|
|
7
7
|
import * as swr from 'swr';
|
|
@@ -734,6 +734,39 @@ declare const usePlusMemberDeliveryCodes: ({ deliveryData, }: {
|
|
|
734
734
|
deliveryData?: DeliveryData;
|
|
735
735
|
}) => string[] | undefined;
|
|
736
736
|
|
|
737
|
+
interface UseUpdatePlusMemberDeliveryOptionsProps {
|
|
738
|
+
/** Delivery data containing custom attributes */
|
|
739
|
+
deliveryData?: DeliveryData;
|
|
740
|
+
/** SWR mutation configuration */
|
|
741
|
+
options?: SWRMutationConfiguration<any, Error, 'update-cart-delivery-options', CartSelectedDeliveryOptionInput[]>;
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Hook to update cart delivery options based on plus member delivery data
|
|
745
|
+
*
|
|
746
|
+
* This hook extracts the selected delivery option from delivery custom data and
|
|
747
|
+
* maps it to the appropriate delivery option handle from the cart's deliveryGroups.
|
|
748
|
+
* It then triggers the update-cart-delivery-options mutation to apply the selection.
|
|
749
|
+
*
|
|
750
|
+
* The hook handles:
|
|
751
|
+
* - Extracting delivery option code from deliveryCustomData.selected_delivery_option
|
|
752
|
+
* - Finding the matching delivery option in cart.deliveryGroups
|
|
753
|
+
* - Triggering the cart update with the correct delivery option handle
|
|
754
|
+
*
|
|
755
|
+
* @param props - Hook properties
|
|
756
|
+
* @returns useSWRMutation result with trigger and loading state
|
|
757
|
+
*
|
|
758
|
+
* @example
|
|
759
|
+
* ```tsx
|
|
760
|
+
* const { trigger, isMutating } = useUpdatePlusMemberDeliveryOptions({
|
|
761
|
+
* deliveryData,
|
|
762
|
+
* })
|
|
763
|
+
*
|
|
764
|
+
* // Trigger update
|
|
765
|
+
* await trigger()
|
|
766
|
+
* ```
|
|
767
|
+
*/
|
|
768
|
+
declare const useUpdatePlusMemberDeliveryOptions: ({ deliveryData, options, }: UseUpdatePlusMemberDeliveryOptionsProps) => swr_mutation.SWRMutationResponse<any, Error, "update-cart-delivery-options", CartSelectedDeliveryOptionInput[]>;
|
|
769
|
+
|
|
737
770
|
type Attribute = {
|
|
738
771
|
key: string;
|
|
739
772
|
value: string;
|
|
@@ -812,7 +845,7 @@ type ExportCart = {
|
|
|
812
845
|
};
|
|
813
846
|
taxesIncluded?: boolean;
|
|
814
847
|
lineItems: ExportLineItem[];
|
|
815
|
-
|
|
848
|
+
totalLineItemsDiscount?: number;
|
|
816
849
|
orderDiscounts?: number;
|
|
817
850
|
lineItemsSubtotalPrice: number;
|
|
818
851
|
subtotalPrice: number;
|
|
@@ -1946,4 +1979,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
1946
1979
|
*/
|
|
1947
1980
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
1948
1981
|
|
|
1949
|
-
export { PriceBasePriceType as $, type AddCartLinesInput as A, type BuyNowInput as B, type CreateCartInput as C, type DiscountLabel as D, type Config as E, type GiftTier as F, type GiftProduct as G, type RewardItem as H, type GiftProductItem as I, RuleType as J, BuyRuleType as K, type FunctionGiftResult as L, type MainProductInfo as M, type FormattedGift as N, type OrderDiscountResult as O, type CartLineInput as P, type AutoFreeGiftItem as Q, type RemoveCartLinesInput as R, SpendMoneyType as S, type AutoFreeGiftList as T, type UpdateCartAttributesInput as U, type VariantItem as V, OrderDiscountType as W, OrderBasePriceType as X, type TieredDiscount as Y, type OrderDiscountConfig as Z, PriceDiscountType as _, useAddCartLines as a, type ShippingMethodsContext as a$, type PriceDiscountConfig as a0, currencyCodeMapping as a1, defaultSWRMutationConfiguration as a2, CUSTOMER_ATTRIBUTE_KEY as a3, CUSTOMER_SCRIPT_GIFT_KEY as a4, CODE_AMOUNT_KEY as a5, SCRIPT_CODE_AMOUNT_KEY as a6, MAIN_PRODUCT_CODE as a7, getQuery as a8, atobID as a9, type VideoMedia as aA, type VariantMedia as aB, useVariantMedia as aC, type UseCollectionOptions as aD, useCollection as aE, type UseAllCollectionsOptions as aF, useAllCollections as aG, type UseCollectionsOptions as aH, useCollections as aI, type UseBlogOptions as aJ, useBlog as aK, type UseAllBlogsOptions as aL, useAllBlogs as aM, type UseArticleOptions as aN, useArticle as aO, type UseArticlesOptions as aP, useArticles as aQ, type UseArticlesInBlogOptions as aR, useArticlesInBlog as aS, type SearchResultType as aT, type SearchResultItem as aU, type SearchResult as aV, type UseSearchOptions as aW, useSearch as aX, type SiteInfo as aY, type UseSiteOptions as aZ, useSite as a_, btoaID as aa, normalizeAddToCartLines as ab, createMockCartFromLines as ac, getMatchedMainProductSubTotal as ad, safeParse as ae, getDiscountEnvAttributeValue as af, checkAttributesUpdateNeeded as ag, preCheck as ah, formatScriptAutoFreeGift as ai, formatFunctionAutoFreeGift as aj, useSelectedOptions as ak, type SelectedOptionsResult as al, type UseProductOptions as am, useProduct as an, type UseAllProductsOptions as ao, useAllProducts as ap, type UseProductsByHandlesOptions as aq, useProductsByHandles as ar, type Options as as, useVariant as at, type UsePriceOptions as au, type UsePriceResult as av, usePrice as aw, useProductUrl as ax, useUpdateVariantQuery as ay, type ImageMedia as az, useUpdateCartLines as b, type PlusMemberContextValue as b0, PlusMemberContext as b1, usePlusMemberContext as b2, usePlusMonthlyProductVariant as b3, usePlusAnnualProductVariant as b4, type UseShippingMethodsOptions as b5, type UseShippingMethodsResult as b6, useShippingMethods as b7, useShippingMethodAvailableCheck as b8, useReplaceCartPlusMember as b9, type
|
|
1982
|
+
export { PriceBasePriceType as $, type AddCartLinesInput as A, type BuyNowInput as B, type CreateCartInput as C, type DiscountLabel as D, type Config as E, type GiftTier as F, type GiftProduct as G, type RewardItem as H, type GiftProductItem as I, RuleType as J, BuyRuleType as K, type FunctionGiftResult as L, type MainProductInfo as M, type FormattedGift as N, type OrderDiscountResult as O, type CartLineInput as P, type AutoFreeGiftItem as Q, type RemoveCartLinesInput as R, SpendMoneyType as S, type AutoFreeGiftList as T, type UpdateCartAttributesInput as U, type VariantItem as V, OrderDiscountType as W, OrderBasePriceType as X, type TieredDiscount as Y, type OrderDiscountConfig as Z, PriceDiscountType as _, useAddCartLines as a, type ShippingMethodsContext as a$, type PriceDiscountConfig as a0, currencyCodeMapping as a1, defaultSWRMutationConfiguration as a2, CUSTOMER_ATTRIBUTE_KEY as a3, CUSTOMER_SCRIPT_GIFT_KEY as a4, CODE_AMOUNT_KEY as a5, SCRIPT_CODE_AMOUNT_KEY as a6, MAIN_PRODUCT_CODE as a7, getQuery as a8, atobID as a9, type VideoMedia as aA, type VariantMedia as aB, useVariantMedia as aC, type UseCollectionOptions as aD, useCollection as aE, type UseAllCollectionsOptions as aF, useAllCollections as aG, type UseCollectionsOptions as aH, useCollections as aI, type UseBlogOptions as aJ, useBlog as aK, type UseAllBlogsOptions as aL, useAllBlogs as aM, type UseArticleOptions as aN, useArticle as aO, type UseArticlesOptions as aP, useArticles as aQ, type UseArticlesInBlogOptions as aR, useArticlesInBlog as aS, type SearchResultType as aT, type SearchResultItem as aU, type SearchResult as aV, type UseSearchOptions as aW, useSearch as aX, type SiteInfo as aY, type UseSiteOptions as aZ, useSite as a_, btoaID as aa, normalizeAddToCartLines as ab, createMockCartFromLines as ac, getMatchedMainProductSubTotal as ad, safeParse as ae, getDiscountEnvAttributeValue as af, checkAttributesUpdateNeeded as ag, preCheck as ah, formatScriptAutoFreeGift as ai, formatFunctionAutoFreeGift as aj, useSelectedOptions as ak, type SelectedOptionsResult as al, type UseProductOptions as am, useProduct as an, type UseAllProductsOptions as ao, useAllProducts as ap, type UseProductsByHandlesOptions as aq, useProductsByHandles as ar, type Options as as, useVariant as at, type UsePriceOptions as au, type UsePriceResult as av, usePrice as aw, useProductUrl as ax, useUpdateVariantQuery as ay, type ImageMedia as az, useUpdateCartLines as b, type PlusMemberContextValue as b0, PlusMemberContext as b1, usePlusMemberContext as b2, usePlusMonthlyProductVariant as b3, usePlusAnnualProductVariant as b4, type UseShippingMethodsOptions as b5, type UseShippingMethodsResult as b6, useShippingMethods as b7, useShippingMethodAvailableCheck as b8, useReplaceCartPlusMember as b9, type Discount as bA, type Image as bB, type Measurement as bC, type ExportSelectedOption as bD, type ExportProductVariant as bE, type ExportDiscountAllocations as bF, type ExportLineItem as bG, type ExportDiscounts as bH, type ExportCart as bI, usePlusMemberDeliveryCodes as ba, type UseUpdatePlusMemberDeliveryOptionsProps as bb, useUpdatePlusMemberDeliveryOptions as bc, usePlusMemberItemCustomAttributes as bd, type CustomerOrder as be, type Customer as bf, usePlusMemberCheckoutCustomAttributes as bg, type UseAutoRemovePlusMemberInCartProps as bh, useAutoRemovePlusMemberInCart as bi, type UseHasPlusMemberInCartProps as bj, type HasPlusMemberInCartResult as bk, useHasPlusMemberInCart as bl, useAddPlusMemberProductsToCart as bm, type PlusMemberProviderProps as bn, PlusMemberProvider as bo, type UseIntersectionOptions as bp, useIntersection as bq, type UseExposureOptions as br, useExposure as bs, type GeoLocationData as bt, type LocaleMapping as bu, type UseGeoLocationOptions as bv, useGeoLocation as bw, getCachedGeoLocation as bx, clearGeoLocationCache as by, type Attribute as bz, useRemoveCartLines as c, type ApplyCartCodesInput as d, useApplyCartCodes as e, type RemoveCartCodesInput as f, useRemoveCartCodes as g, useUpdateCartAttributes as h, type UseBuyNowOptions as i, useBuyNow as j, useCalcAutoFreeGift as k, type UseCalcGiftsFromLinesOptions as l, type UseCalcGiftsFromLinesResult as m, useCalcGiftsFromLines as n, useCalcOrderDiscount as o, getReferralAttributes as p, useCartAttributes as q, useCartItemQuantityLimit as r, type UseScriptAutoFreeGiftResult as s, useScriptAutoFreeGift as t, useCreateCart as u, useUpdateLineCodeAmountAttributes as v, type AutoFreeGift as w, type AutoFreeGiftMainProduct as x, type AutoFreeGiftConfig as y, type RuleCondition as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
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 as CartLineInput$1, NormalizedCart, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, Attribute as Attribute$1, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
|
|
4
|
+
import { CartLineInput as CartLineInput$1, NormalizedCart, UpdateCartLinesOptions, HasMetafieldsIdentifier, NormalizedProduct, NormalizedProductVariant, NormalizedLineItem, CartSelectedDeliveryOptionInput, Attribute as Attribute$1, Media, NormalizedCollection, CollectionsConnection, NormalizedBlog, NormalizedArticle } from '@anker-in/shopify-sdk';
|
|
5
5
|
import { A as AddToCartLineItem, G as GtmParams, B as BuyNowTrackConfig, d as PlusMemberShippingMethodConfig, e as PlusMemberSettingsMetafields, D as DeliveryPlusType, f as SelectedPlusMemberProduct, i as DeliveryData } from './types-CICUnw0v.mjs';
|
|
6
6
|
import Decimal from 'decimal.js';
|
|
7
7
|
import * as swr from 'swr';
|
|
@@ -734,6 +734,39 @@ declare const usePlusMemberDeliveryCodes: ({ deliveryData, }: {
|
|
|
734
734
|
deliveryData?: DeliveryData;
|
|
735
735
|
}) => string[] | undefined;
|
|
736
736
|
|
|
737
|
+
interface UseUpdatePlusMemberDeliveryOptionsProps {
|
|
738
|
+
/** Delivery data containing custom attributes */
|
|
739
|
+
deliveryData?: DeliveryData;
|
|
740
|
+
/** SWR mutation configuration */
|
|
741
|
+
options?: SWRMutationConfiguration<any, Error, 'update-cart-delivery-options', CartSelectedDeliveryOptionInput[]>;
|
|
742
|
+
}
|
|
743
|
+
/**
|
|
744
|
+
* Hook to update cart delivery options based on plus member delivery data
|
|
745
|
+
*
|
|
746
|
+
* This hook extracts the selected delivery option from delivery custom data and
|
|
747
|
+
* maps it to the appropriate delivery option handle from the cart's deliveryGroups.
|
|
748
|
+
* It then triggers the update-cart-delivery-options mutation to apply the selection.
|
|
749
|
+
*
|
|
750
|
+
* The hook handles:
|
|
751
|
+
* - Extracting delivery option code from deliveryCustomData.selected_delivery_option
|
|
752
|
+
* - Finding the matching delivery option in cart.deliveryGroups
|
|
753
|
+
* - Triggering the cart update with the correct delivery option handle
|
|
754
|
+
*
|
|
755
|
+
* @param props - Hook properties
|
|
756
|
+
* @returns useSWRMutation result with trigger and loading state
|
|
757
|
+
*
|
|
758
|
+
* @example
|
|
759
|
+
* ```tsx
|
|
760
|
+
* const { trigger, isMutating } = useUpdatePlusMemberDeliveryOptions({
|
|
761
|
+
* deliveryData,
|
|
762
|
+
* })
|
|
763
|
+
*
|
|
764
|
+
* // Trigger update
|
|
765
|
+
* await trigger()
|
|
766
|
+
* ```
|
|
767
|
+
*/
|
|
768
|
+
declare const useUpdatePlusMemberDeliveryOptions: ({ deliveryData, options, }: UseUpdatePlusMemberDeliveryOptionsProps) => swr_mutation.SWRMutationResponse<any, Error, "update-cart-delivery-options", CartSelectedDeliveryOptionInput[]>;
|
|
769
|
+
|
|
737
770
|
type Attribute = {
|
|
738
771
|
key: string;
|
|
739
772
|
value: string;
|
|
@@ -812,7 +845,7 @@ type ExportCart = {
|
|
|
812
845
|
};
|
|
813
846
|
taxesIncluded?: boolean;
|
|
814
847
|
lineItems: ExportLineItem[];
|
|
815
|
-
|
|
848
|
+
totalLineItemsDiscount?: number;
|
|
816
849
|
orderDiscounts?: number;
|
|
817
850
|
lineItemsSubtotalPrice: number;
|
|
818
851
|
subtotalPrice: number;
|
|
@@ -1946,4 +1979,4 @@ declare function getCachedGeoLocation(cacheKey?: string): GeoLocationData | unde
|
|
|
1946
1979
|
*/
|
|
1947
1980
|
declare function clearGeoLocationCache(cacheKey?: string): void;
|
|
1948
1981
|
|
|
1949
|
-
export { PriceBasePriceType as $, type AddCartLinesInput as A, type BuyNowInput as B, type CreateCartInput as C, type DiscountLabel as D, type Config as E, type GiftTier as F, type GiftProduct as G, type RewardItem as H, type GiftProductItem as I, RuleType as J, BuyRuleType as K, type FunctionGiftResult as L, type MainProductInfo as M, type FormattedGift as N, type OrderDiscountResult as O, type CartLineInput as P, type AutoFreeGiftItem as Q, type RemoveCartLinesInput as R, SpendMoneyType as S, type AutoFreeGiftList as T, type UpdateCartAttributesInput as U, type VariantItem as V, OrderDiscountType as W, OrderBasePriceType as X, type TieredDiscount as Y, type OrderDiscountConfig as Z, PriceDiscountType as _, useAddCartLines as a, type ShippingMethodsContext as a$, type PriceDiscountConfig as a0, currencyCodeMapping as a1, defaultSWRMutationConfiguration as a2, CUSTOMER_ATTRIBUTE_KEY as a3, CUSTOMER_SCRIPT_GIFT_KEY as a4, CODE_AMOUNT_KEY as a5, SCRIPT_CODE_AMOUNT_KEY as a6, MAIN_PRODUCT_CODE as a7, getQuery as a8, atobID as a9, type VideoMedia as aA, type VariantMedia as aB, useVariantMedia as aC, type UseCollectionOptions as aD, useCollection as aE, type UseAllCollectionsOptions as aF, useAllCollections as aG, type UseCollectionsOptions as aH, useCollections as aI, type UseBlogOptions as aJ, useBlog as aK, type UseAllBlogsOptions as aL, useAllBlogs as aM, type UseArticleOptions as aN, useArticle as aO, type UseArticlesOptions as aP, useArticles as aQ, type UseArticlesInBlogOptions as aR, useArticlesInBlog as aS, type SearchResultType as aT, type SearchResultItem as aU, type SearchResult as aV, type UseSearchOptions as aW, useSearch as aX, type SiteInfo as aY, type UseSiteOptions as aZ, useSite as a_, btoaID as aa, normalizeAddToCartLines as ab, createMockCartFromLines as ac, getMatchedMainProductSubTotal as ad, safeParse as ae, getDiscountEnvAttributeValue as af, checkAttributesUpdateNeeded as ag, preCheck as ah, formatScriptAutoFreeGift as ai, formatFunctionAutoFreeGift as aj, useSelectedOptions as ak, type SelectedOptionsResult as al, type UseProductOptions as am, useProduct as an, type UseAllProductsOptions as ao, useAllProducts as ap, type UseProductsByHandlesOptions as aq, useProductsByHandles as ar, type Options as as, useVariant as at, type UsePriceOptions as au, type UsePriceResult as av, usePrice as aw, useProductUrl as ax, useUpdateVariantQuery as ay, type ImageMedia as az, useUpdateCartLines as b, type PlusMemberContextValue as b0, PlusMemberContext as b1, usePlusMemberContext as b2, usePlusMonthlyProductVariant as b3, usePlusAnnualProductVariant as b4, type UseShippingMethodsOptions as b5, type UseShippingMethodsResult as b6, useShippingMethods as b7, useShippingMethodAvailableCheck as b8, useReplaceCartPlusMember as b9, type
|
|
1982
|
+
export { PriceBasePriceType as $, type AddCartLinesInput as A, type BuyNowInput as B, type CreateCartInput as C, type DiscountLabel as D, type Config as E, type GiftTier as F, type GiftProduct as G, type RewardItem as H, type GiftProductItem as I, RuleType as J, BuyRuleType as K, type FunctionGiftResult as L, type MainProductInfo as M, type FormattedGift as N, type OrderDiscountResult as O, type CartLineInput as P, type AutoFreeGiftItem as Q, type RemoveCartLinesInput as R, SpendMoneyType as S, type AutoFreeGiftList as T, type UpdateCartAttributesInput as U, type VariantItem as V, OrderDiscountType as W, OrderBasePriceType as X, type TieredDiscount as Y, type OrderDiscountConfig as Z, PriceDiscountType as _, useAddCartLines as a, type ShippingMethodsContext as a$, type PriceDiscountConfig as a0, currencyCodeMapping as a1, defaultSWRMutationConfiguration as a2, CUSTOMER_ATTRIBUTE_KEY as a3, CUSTOMER_SCRIPT_GIFT_KEY as a4, CODE_AMOUNT_KEY as a5, SCRIPT_CODE_AMOUNT_KEY as a6, MAIN_PRODUCT_CODE as a7, getQuery as a8, atobID as a9, type VideoMedia as aA, type VariantMedia as aB, useVariantMedia as aC, type UseCollectionOptions as aD, useCollection as aE, type UseAllCollectionsOptions as aF, useAllCollections as aG, type UseCollectionsOptions as aH, useCollections as aI, type UseBlogOptions as aJ, useBlog as aK, type UseAllBlogsOptions as aL, useAllBlogs as aM, type UseArticleOptions as aN, useArticle as aO, type UseArticlesOptions as aP, useArticles as aQ, type UseArticlesInBlogOptions as aR, useArticlesInBlog as aS, type SearchResultType as aT, type SearchResultItem as aU, type SearchResult as aV, type UseSearchOptions as aW, useSearch as aX, type SiteInfo as aY, type UseSiteOptions as aZ, useSite as a_, btoaID as aa, normalizeAddToCartLines as ab, createMockCartFromLines as ac, getMatchedMainProductSubTotal as ad, safeParse as ae, getDiscountEnvAttributeValue as af, checkAttributesUpdateNeeded as ag, preCheck as ah, formatScriptAutoFreeGift as ai, formatFunctionAutoFreeGift as aj, useSelectedOptions as ak, type SelectedOptionsResult as al, type UseProductOptions as am, useProduct as an, type UseAllProductsOptions as ao, useAllProducts as ap, type UseProductsByHandlesOptions as aq, useProductsByHandles as ar, type Options as as, useVariant as at, type UsePriceOptions as au, type UsePriceResult as av, usePrice as aw, useProductUrl as ax, useUpdateVariantQuery as ay, type ImageMedia as az, useUpdateCartLines as b, type PlusMemberContextValue as b0, PlusMemberContext as b1, usePlusMemberContext as b2, usePlusMonthlyProductVariant as b3, usePlusAnnualProductVariant as b4, type UseShippingMethodsOptions as b5, type UseShippingMethodsResult as b6, useShippingMethods as b7, useShippingMethodAvailableCheck as b8, useReplaceCartPlusMember as b9, type Discount as bA, type Image as bB, type Measurement as bC, type ExportSelectedOption as bD, type ExportProductVariant as bE, type ExportDiscountAllocations as bF, type ExportLineItem as bG, type ExportDiscounts as bH, type ExportCart as bI, usePlusMemberDeliveryCodes as ba, type UseUpdatePlusMemberDeliveryOptionsProps as bb, useUpdatePlusMemberDeliveryOptions as bc, usePlusMemberItemCustomAttributes as bd, type CustomerOrder as be, type Customer as bf, usePlusMemberCheckoutCustomAttributes as bg, type UseAutoRemovePlusMemberInCartProps as bh, useAutoRemovePlusMemberInCart as bi, type UseHasPlusMemberInCartProps as bj, type HasPlusMemberInCartResult as bk, useHasPlusMemberInCart as bl, useAddPlusMemberProductsToCart as bm, type PlusMemberProviderProps as bn, PlusMemberProvider as bo, type UseIntersectionOptions as bp, useIntersection as bq, type UseExposureOptions as br, useExposure as bs, type GeoLocationData as bt, type LocaleMapping as bu, type UseGeoLocationOptions as bv, useGeoLocation as bw, getCachedGeoLocation as bx, clearGeoLocationCache as by, type Attribute as bz, useRemoveCartLines as c, type ApplyCartCodesInput as d, useApplyCartCodes as e, type RemoveCartCodesInput as f, useRemoveCartCodes as g, useUpdateCartAttributes as h, type UseBuyNowOptions as i, useBuyNow as j, useCalcAutoFreeGift as k, type UseCalcGiftsFromLinesOptions as l, type UseCalcGiftsFromLinesResult as m, useCalcGiftsFromLines as n, useCalcOrderDiscount as o, getReferralAttributes as p, useCartAttributes as q, useCartItemQuantityLimit as r, type UseScriptAutoFreeGiftResult as s, useScriptAutoFreeGift as t, useCreateCart as u, useUpdateLineCodeAmountAttributes as v, type AutoFreeGift as w, type AutoFreeGiftMainProduct as x, type AutoFreeGiftConfig as y, type RuleCondition as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AttributeInput, CartContextValue, CartProvider, CartProviderProps, LoadingState, ShopifyContext, ShopifyContextValue, ShopifyProvider, ShopifyProviderProps, useCartContext, useShopify } from './provider/index.mjs';
|
|
2
2
|
export { b as CartCookieAdapter, C as CookieAdapter, a as CookieOptions, R as RouterAdapter, U as UserContextAdapter } from './types-BLMoxbOk.mjs';
|
|
3
3
|
export { browserCartCookieAdapter, browserCookieAdapter } from './adapters/index.mjs';
|
|
4
|
-
export { A as AddCartLinesInput, d as ApplyCartCodesInput,
|
|
4
|
+
export { A as AddCartLinesInput, d as ApplyCartCodesInput, bz as Attribute, w as AutoFreeGift, y as AutoFreeGiftConfig, Q as AutoFreeGiftItem, T as AutoFreeGiftList, x as AutoFreeGiftMainProduct, B as BuyNowInput, K as BuyRuleType, a5 as CODE_AMOUNT_KEY, a3 as CUSTOMER_ATTRIBUTE_KEY, a4 as CUSTOMER_SCRIPT_GIFT_KEY, P as CartLineInput, E as Config, C as CreateCartInput, bf as Customer, be as CustomerOrder, bA as Discount, D as DiscountLabel, bI as ExportCart, bF as ExportDiscountAllocations, bH as ExportDiscounts, bG as ExportLineItem, bE as ExportProductVariant, bD as ExportSelectedOption, N as FormattedGift, L as FunctionGiftResult, bt as GeoLocationData, G as GiftProduct, I as GiftProductItem, F as GiftTier, bk as HasPlusMemberInCartResult, bB as Image, az as ImageMedia, bu as LocaleMapping, a7 as MAIN_PRODUCT_CODE, M as MainProductInfo, bC as Measurement, as as Options, X as OrderBasePriceType, Z as OrderDiscountConfig, O as OrderDiscountResult, W as OrderDiscountType, b1 as PlusMemberContext, b0 as PlusMemberContextValue, bo as PlusMemberProvider, bn as PlusMemberProviderProps, $ as PriceBasePriceType, a0 as PriceDiscountConfig, _ as PriceDiscountType, f as RemoveCartCodesInput, R as RemoveCartLinesInput, H as RewardItem, z as RuleCondition, J as RuleType, a6 as SCRIPT_CODE_AMOUNT_KEY, aV as SearchResult, aU as SearchResultItem, aT as SearchResultType, al as SelectedOptionsResult, a$ as ShippingMethodsContext, aY as SiteInfo, S as SpendMoneyType, Y as TieredDiscount, U as UpdateCartAttributesInput, aL as UseAllBlogsOptions, aF as UseAllCollectionsOptions, ao as UseAllProductsOptions, aN as UseArticleOptions, aR as UseArticlesInBlogOptions, aP as UseArticlesOptions, bh as UseAutoRemovePlusMemberInCartProps, aJ as UseBlogOptions, i as UseBuyNowOptions, l as UseCalcGiftsFromLinesOptions, m as UseCalcGiftsFromLinesResult, aD as UseCollectionOptions, aH as UseCollectionsOptions, br as UseExposureOptions, bv as UseGeoLocationOptions, bj as UseHasPlusMemberInCartProps, bp as UseIntersectionOptions, au as UsePriceOptions, av as UsePriceResult, am as UseProductOptions, aq as UseProductsByHandlesOptions, s as UseScriptAutoFreeGiftResult, aW as UseSearchOptions, b5 as UseShippingMethodsOptions, b6 as UseShippingMethodsResult, aZ as UseSiteOptions, bb as UseUpdatePlusMemberDeliveryOptionsProps, V as VariantItem, aB as VariantMedia, aA as VideoMedia, a9 as atobID, aa as btoaID, ag as checkAttributesUpdateNeeded, by as clearGeoLocationCache, ac as createMockCartFromLines, a1 as currencyCodeMapping, a2 as defaultSWRMutationConfiguration, aj as formatFunctionAutoFreeGift, ai as formatScriptAutoFreeGift, bx as getCachedGeoLocation, af as getDiscountEnvAttributeValue, ad as getMatchedMainProductSubTotal, a8 as getQuery, p as getReferralAttributes, ab as normalizeAddToCartLines, ah as preCheck, ae as safeParse, a as useAddCartLines, bm as useAddPlusMemberProductsToCart, aM as useAllBlogs, aG as useAllCollections, ap as useAllProducts, e as useApplyCartCodes, aO as useArticle, aQ as useArticles, aS as useArticlesInBlog, bi as useAutoRemovePlusMemberInCart, aK as useBlog, j as useBuyNow, k as useCalcAutoFreeGift, n as useCalcGiftsFromLines, o as useCalcOrderDiscount, q as useCartAttributes, r as useCartItemQuantityLimit, aE as useCollection, aI as useCollections, u as useCreateCart, bs as useExposure, bw as useGeoLocation, bl as useHasPlusMemberInCart, bq as useIntersection, b4 as usePlusAnnualProductVariant, bg as usePlusMemberCheckoutCustomAttributes, b2 as usePlusMemberContext, ba as usePlusMemberDeliveryCodes, bd as usePlusMemberItemCustomAttributes, b3 as usePlusMonthlyProductVariant, aw as usePrice, an as useProduct, ax as useProductUrl, ar as useProductsByHandles, g as useRemoveCartCodes, c as useRemoveCartLines, b9 as useReplaceCartPlusMember, t as useScriptAutoFreeGift, aX as useSearch, ak as useSelectedOptions, b8 as useShippingMethodAvailableCheck, b7 as useShippingMethods, a_ as useSite, h as useUpdateCartAttributes, b as useUpdateCartLines, v as useUpdateLineCodeAmountAttributes, bc as useUpdatePlusMemberDeliveryOptions, ay as useUpdateVariantQuery, at as useVariant, aC as useVariantMedia } from './index-DyExTsmO.mjs';
|
|
5
5
|
export { a as AddToCartInput, A as AddToCartLineItem, B as BuyNowTrackConfig, h as DeliveryCustomData, i as DeliveryData, g as DeliveryOption, D as DeliveryPlusType, G as GtmParams, M as MailingAddress, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, e as PlusMemberSettingsMetafields, d as PlusMemberShippingMethodConfig, c as PlusMemberShippingMethodMetafields, f as SelectedPlusMemberProduct, S as ShippingMethodMode, U as UseAddToCartOptions, j as gaTrack, m as trackAddToCartFBQ, t as trackAddToCartGA, k as trackBeginCheckoutGA, n as trackBuyNowFBQ, l as trackBuyNowGA, u as useAddToCart } from './types-CICUnw0v.mjs';
|
|
6
6
|
export { ShopifyConfig, clearLocalStorage, createShopifyClient, getLocalStorage, removeLocalStorage, setLocalStorage } from '@anker-in/shopify-sdk';
|
|
7
7
|
import 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AttributeInput, CartContextValue, CartProvider, CartProviderProps, LoadingState, ShopifyContext, ShopifyContextValue, ShopifyProvider, ShopifyProviderProps, useCartContext, useShopify } from './provider/index.js';
|
|
2
2
|
export { b as CartCookieAdapter, C as CookieAdapter, a as CookieOptions, R as RouterAdapter, U as UserContextAdapter } from './types-BLMoxbOk.js';
|
|
3
3
|
export { browserCartCookieAdapter, browserCookieAdapter } from './adapters/index.js';
|
|
4
|
-
export { A as AddCartLinesInput, d as ApplyCartCodesInput,
|
|
4
|
+
export { A as AddCartLinesInput, d as ApplyCartCodesInput, bz as Attribute, w as AutoFreeGift, y as AutoFreeGiftConfig, Q as AutoFreeGiftItem, T as AutoFreeGiftList, x as AutoFreeGiftMainProduct, B as BuyNowInput, K as BuyRuleType, a5 as CODE_AMOUNT_KEY, a3 as CUSTOMER_ATTRIBUTE_KEY, a4 as CUSTOMER_SCRIPT_GIFT_KEY, P as CartLineInput, E as Config, C as CreateCartInput, bf as Customer, be as CustomerOrder, bA as Discount, D as DiscountLabel, bI as ExportCart, bF as ExportDiscountAllocations, bH as ExportDiscounts, bG as ExportLineItem, bE as ExportProductVariant, bD as ExportSelectedOption, N as FormattedGift, L as FunctionGiftResult, bt as GeoLocationData, G as GiftProduct, I as GiftProductItem, F as GiftTier, bk as HasPlusMemberInCartResult, bB as Image, az as ImageMedia, bu as LocaleMapping, a7 as MAIN_PRODUCT_CODE, M as MainProductInfo, bC as Measurement, as as Options, X as OrderBasePriceType, Z as OrderDiscountConfig, O as OrderDiscountResult, W as OrderDiscountType, b1 as PlusMemberContext, b0 as PlusMemberContextValue, bo as PlusMemberProvider, bn as PlusMemberProviderProps, $ as PriceBasePriceType, a0 as PriceDiscountConfig, _ as PriceDiscountType, f as RemoveCartCodesInput, R as RemoveCartLinesInput, H as RewardItem, z as RuleCondition, J as RuleType, a6 as SCRIPT_CODE_AMOUNT_KEY, aV as SearchResult, aU as SearchResultItem, aT as SearchResultType, al as SelectedOptionsResult, a$ as ShippingMethodsContext, aY as SiteInfo, S as SpendMoneyType, Y as TieredDiscount, U as UpdateCartAttributesInput, aL as UseAllBlogsOptions, aF as UseAllCollectionsOptions, ao as UseAllProductsOptions, aN as UseArticleOptions, aR as UseArticlesInBlogOptions, aP as UseArticlesOptions, bh as UseAutoRemovePlusMemberInCartProps, aJ as UseBlogOptions, i as UseBuyNowOptions, l as UseCalcGiftsFromLinesOptions, m as UseCalcGiftsFromLinesResult, aD as UseCollectionOptions, aH as UseCollectionsOptions, br as UseExposureOptions, bv as UseGeoLocationOptions, bj as UseHasPlusMemberInCartProps, bp as UseIntersectionOptions, au as UsePriceOptions, av as UsePriceResult, am as UseProductOptions, aq as UseProductsByHandlesOptions, s as UseScriptAutoFreeGiftResult, aW as UseSearchOptions, b5 as UseShippingMethodsOptions, b6 as UseShippingMethodsResult, aZ as UseSiteOptions, bb as UseUpdatePlusMemberDeliveryOptionsProps, V as VariantItem, aB as VariantMedia, aA as VideoMedia, a9 as atobID, aa as btoaID, ag as checkAttributesUpdateNeeded, by as clearGeoLocationCache, ac as createMockCartFromLines, a1 as currencyCodeMapping, a2 as defaultSWRMutationConfiguration, aj as formatFunctionAutoFreeGift, ai as formatScriptAutoFreeGift, bx as getCachedGeoLocation, af as getDiscountEnvAttributeValue, ad as getMatchedMainProductSubTotal, a8 as getQuery, p as getReferralAttributes, ab as normalizeAddToCartLines, ah as preCheck, ae as safeParse, a as useAddCartLines, bm as useAddPlusMemberProductsToCart, aM as useAllBlogs, aG as useAllCollections, ap as useAllProducts, e as useApplyCartCodes, aO as useArticle, aQ as useArticles, aS as useArticlesInBlog, bi as useAutoRemovePlusMemberInCart, aK as useBlog, j as useBuyNow, k as useCalcAutoFreeGift, n as useCalcGiftsFromLines, o as useCalcOrderDiscount, q as useCartAttributes, r as useCartItemQuantityLimit, aE as useCollection, aI as useCollections, u as useCreateCart, bs as useExposure, bw as useGeoLocation, bl as useHasPlusMemberInCart, bq as useIntersection, b4 as usePlusAnnualProductVariant, bg as usePlusMemberCheckoutCustomAttributes, b2 as usePlusMemberContext, ba as usePlusMemberDeliveryCodes, bd as usePlusMemberItemCustomAttributes, b3 as usePlusMonthlyProductVariant, aw as usePrice, an as useProduct, ax as useProductUrl, ar as useProductsByHandles, g as useRemoveCartCodes, c as useRemoveCartLines, b9 as useReplaceCartPlusMember, t as useScriptAutoFreeGift, aX as useSearch, ak as useSelectedOptions, b8 as useShippingMethodAvailableCheck, b7 as useShippingMethods, a_ as useSite, h as useUpdateCartAttributes, b as useUpdateCartLines, v as useUpdateLineCodeAmountAttributes, bc as useUpdatePlusMemberDeliveryOptions, ay as useUpdateVariantQuery, at as useVariant, aC as useVariantMedia } from './index-DMLI1Lh0.js';
|
|
5
5
|
export { a as AddToCartInput, A as AddToCartLineItem, B as BuyNowTrackConfig, h as DeliveryCustomData, i as DeliveryData, g as DeliveryOption, D as DeliveryPlusType, G as GtmParams, M as MailingAddress, P as PLUS_MEMBER_TYPE, b as PlusMemberMode, e as PlusMemberSettingsMetafields, d as PlusMemberShippingMethodConfig, c as PlusMemberShippingMethodMetafields, f as SelectedPlusMemberProduct, S as ShippingMethodMode, U as UseAddToCartOptions, j as gaTrack, m as trackAddToCartFBQ, t as trackAddToCartGA, k as trackBeginCheckoutGA, n as trackBuyNowFBQ, l as trackBuyNowGA, u as useAddToCart } from './types-CICUnw0v.js';
|
|
6
6
|
export { ShopifyConfig, clearLocalStorage, createShopifyClient, getLocalStorage, removeLocalStorage, setLocalStorage } from '@anker-in/shopify-sdk';
|
|
7
7
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -203,7 +203,7 @@ function createMockCartFromLines(lines, existingCart) {
|
|
|
203
203
|
currency: existingCart?.currency || { code: "USD" },
|
|
204
204
|
taxesIncluded: existingCart?.taxesIncluded,
|
|
205
205
|
lineItems: normalizedLines,
|
|
206
|
-
|
|
206
|
+
totalLineItemsDiscount: 0,
|
|
207
207
|
orderDiscounts: 0,
|
|
208
208
|
lineItemsSubtotalPrice: subtotalPrice,
|
|
209
209
|
subtotalPrice,
|
|
@@ -2636,6 +2636,67 @@ var usePlusMemberDeliveryCodes = ({
|
|
|
2636
2636
|
[deliveryData]
|
|
2637
2637
|
);
|
|
2638
2638
|
};
|
|
2639
|
+
function useUpdateCartDeliveryOptions(mutate, metafieldIdentifiers, options) {
|
|
2640
|
+
const { client, locale, cartCookieAdapter } = useShopify();
|
|
2641
|
+
const updateDeliveryOptions = react.useCallback(
|
|
2642
|
+
async (_key, { arg }) => {
|
|
2643
|
+
const updatedCart = await shopifySdk.updateCartDeliveryOptions(client, {
|
|
2644
|
+
...arg,
|
|
2645
|
+
metafieldIdentifiers,
|
|
2646
|
+
cookieAdapter: cartCookieAdapter
|
|
2647
|
+
});
|
|
2648
|
+
console.log("useUpdateCartDeliveryOptions updatedCart", updatedCart);
|
|
2649
|
+
if (updatedCart) {
|
|
2650
|
+
mutate(updatedCart);
|
|
2651
|
+
}
|
|
2652
|
+
return updatedCart;
|
|
2653
|
+
},
|
|
2654
|
+
[client, locale, cartCookieAdapter, mutate]
|
|
2655
|
+
);
|
|
2656
|
+
return useSWRMutation__default.default("update-cart-delivery-options", updateDeliveryOptions, options);
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2659
|
+
// src/hooks/member/plus/use-update-plus-member-delivery-options.ts
|
|
2660
|
+
var useUpdatePlusMemberDeliveryOptions = ({
|
|
2661
|
+
deliveryData,
|
|
2662
|
+
options
|
|
2663
|
+
}) => {
|
|
2664
|
+
const { cart, mutateCart: mutate, metafieldIdentifiers } = useCartContext();
|
|
2665
|
+
const { trigger: updateCartDeliveryOptions2, isMutating } = useUpdateCartDeliveryOptions(
|
|
2666
|
+
mutate,
|
|
2667
|
+
metafieldIdentifiers
|
|
2668
|
+
);
|
|
2669
|
+
const deliveryOptions = react.useMemo(() => {
|
|
2670
|
+
const deliveryGroupId = cart?.deliveryGroups?.[0]?.id;
|
|
2671
|
+
const selectedOptionCode = deliveryData?.deliveryCustomData?.selected_delivery_option;
|
|
2672
|
+
if (!deliveryGroupId || !selectedOptionCode) {
|
|
2673
|
+
return [];
|
|
2674
|
+
}
|
|
2675
|
+
const deliveryGroup = cart?.deliveryGroups?.find((group) => group?.id === deliveryGroupId);
|
|
2676
|
+
const matchedOption = deliveryGroup?.deliveryOptions?.find(
|
|
2677
|
+
(option) => option?.code === selectedOptionCode
|
|
2678
|
+
);
|
|
2679
|
+
if (!matchedOption?.handle) {
|
|
2680
|
+
return [];
|
|
2681
|
+
}
|
|
2682
|
+
return [
|
|
2683
|
+
{
|
|
2684
|
+
deliveryGroupId,
|
|
2685
|
+
deliveryOptionHandle: matchedOption.handle
|
|
2686
|
+
}
|
|
2687
|
+
];
|
|
2688
|
+
}, [deliveryData, cart]);
|
|
2689
|
+
const handler = react.useCallback(async () => {
|
|
2690
|
+
const updatedCart = await updateCartDeliveryOptions2({
|
|
2691
|
+
selectedDeliveryOptions: deliveryOptions
|
|
2692
|
+
});
|
|
2693
|
+
if (updatedCart && mutate) {
|
|
2694
|
+
mutate(updatedCart);
|
|
2695
|
+
}
|
|
2696
|
+
return updatedCart;
|
|
2697
|
+
}, [deliveryOptions, mutate, updateCartDeliveryOptions2]);
|
|
2698
|
+
return useSWRMutation__default.default("update-cart-delivery-options", handler, options);
|
|
2699
|
+
};
|
|
2639
2700
|
var usePlusMemberItemCustomAttributes = ({
|
|
2640
2701
|
deliveryData
|
|
2641
2702
|
}) => {
|
|
@@ -3375,6 +3436,7 @@ exports.useSite = useSite;
|
|
|
3375
3436
|
exports.useUpdateCartAttributes = useUpdateCartAttributes;
|
|
3376
3437
|
exports.useUpdateCartLines = useUpdateCartLines;
|
|
3377
3438
|
exports.useUpdateLineCodeAmountAttributes = useUpdateLineCodeAmountAttributes;
|
|
3439
|
+
exports.useUpdatePlusMemberDeliveryOptions = useUpdatePlusMemberDeliveryOptions;
|
|
3378
3440
|
exports.useUpdateVariantQuery = useUpdateVariantQuery;
|
|
3379
3441
|
exports.useVariant = useVariant;
|
|
3380
3442
|
exports.useVariantMedia = useVariantMedia;
|