@anker-in/shopify-react 0.1.1-beta.32 → 0.1.1-beta.34
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/adapters/index.d.mts +18 -3
- package/dist/adapters/index.d.ts +18 -3
- package/dist/adapters/index.js +15 -0
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +15 -1
- package/dist/adapters/index.mjs.map +1 -1
- package/dist/hooks/index.d.mts +3 -3
- package/dist/hooks/index.d.ts +3 -3
- package/dist/hooks/index.js +11 -8
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +11 -8
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +32 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -11
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +4 -2
- package/dist/provider/index.d.ts +4 -2
- package/dist/provider/index.js +6 -3
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +6 -3
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-Dt0DUG00.d.mts → types-SKDHauqk.d.mts} +14 -1
- package/dist/{types-Dt0DUG00.d.ts → types-SKDHauqk.d.ts} +14 -1
- package/package.json +1 -1
package/dist/hooks/index.mjs
CHANGED
|
@@ -70,7 +70,7 @@ function normalizeAddToCartLines(lines) {
|
|
|
70
70
|
const product = variant.product;
|
|
71
71
|
const quantity = line.quantity || 1;
|
|
72
72
|
const originalPrice = variant.price?.amount ? Number(variant.price.amount) : 0;
|
|
73
|
-
const finalPrice = variant.finalPrice?.amount ? Number(variant.finalPrice
|
|
73
|
+
const finalPrice = variant.finalPrice?.amount === void 0 ? originalPrice : Number(variant.finalPrice?.amount);
|
|
74
74
|
const subtotalAmount = originalPrice * quantity;
|
|
75
75
|
const totalAmount = finalPrice * quantity;
|
|
76
76
|
return {
|
|
@@ -739,7 +739,7 @@ var trackAddToCartGA = ({
|
|
|
739
739
|
const currencyCode = variant.product?.price?.currencyCode;
|
|
740
740
|
const totalPrice = lineItems?.reduce(
|
|
741
741
|
(prev, { variant: variant2 }) => prev.plus(
|
|
742
|
-
variant2?.finalPrice?.amount
|
|
742
|
+
variant2?.finalPrice?.amount === void 0 ? Number(variant2?.price?.amount) || 0 : Number(variant2?.finalPrice?.amount) || 0
|
|
743
743
|
),
|
|
744
744
|
new Decimal2(0)
|
|
745
745
|
).toNumber();
|
|
@@ -775,7 +775,7 @@ var trackBuyNowGA = ({
|
|
|
775
775
|
const currencyCode = variant.product?.price?.currencyCode || variant.price?.currencyCode;
|
|
776
776
|
const totalPrice = lineItems?.reduce(
|
|
777
777
|
(prev, { variant: variant2 }) => prev.plus(
|
|
778
|
-
variant2?.finalPrice?.amount
|
|
778
|
+
variant2?.finalPrice?.amount === void 0 ? Number(variant2?.price?.amount) || 0 : Number(variant2?.finalPrice?.amount) || 0
|
|
779
779
|
),
|
|
780
780
|
new Decimal2(0)
|
|
781
781
|
).toNumber();
|
|
@@ -948,7 +948,7 @@ var getLinesWithFunctionAttributes = (lineItems) => {
|
|
|
948
948
|
key: CUSTOMER_ATTRIBUTE_KEY,
|
|
949
949
|
value: JSON.stringify({
|
|
950
950
|
is_gift: false,
|
|
951
|
-
discounted_amount: Number(line.variant?.
|
|
951
|
+
discounted_amount: line.variant?.finalPrice?.amount === void 0 ? Number(line.variant?.price?.amount) * (line.quantity || 1) : Number(line.variant?.finalPrice?.amount) * (line.quantity || 1)
|
|
952
952
|
})
|
|
953
953
|
}
|
|
954
954
|
]);
|
|
@@ -959,7 +959,7 @@ var getLinesWithFunctionAttributes = (lineItems) => {
|
|
|
959
959
|
|
|
960
960
|
// src/hooks/cart/use-add-to-cart.ts
|
|
961
961
|
function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
962
|
-
const { client, config, locale, cartCookieAdapter, userAdapter } = useShopify();
|
|
962
|
+
const { client, config, locale, cartCookieAdapter, userAdapter, performanceAdapter } = useShopify();
|
|
963
963
|
const { cart, addCustomAttributes } = useCartContext();
|
|
964
964
|
const { trigger: applyCartCodes } = useApplyCartCodes();
|
|
965
965
|
const { trigger: removeInvalidCodes } = useRemoveCartCodes();
|
|
@@ -980,6 +980,7 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
|
980
980
|
if (!lineItems || lineItems.length === 0) {
|
|
981
981
|
return;
|
|
982
982
|
}
|
|
983
|
+
performanceAdapter?.addToCartStart();
|
|
983
984
|
const linesWithAttributes = getLinesWithAttributes({
|
|
984
985
|
cart,
|
|
985
986
|
lineItems
|
|
@@ -1001,6 +1002,7 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
|
1001
1002
|
buyerIdentity
|
|
1002
1003
|
});
|
|
1003
1004
|
if (!resultCart) {
|
|
1005
|
+
performanceAdapter?.addToCartEnd();
|
|
1004
1006
|
return void 0;
|
|
1005
1007
|
}
|
|
1006
1008
|
console.log("npm addCartLines resultCart", resultCart);
|
|
@@ -1035,9 +1037,10 @@ function useAddToCart({ withTrack = true } = {}, swrOptions) {
|
|
|
1035
1037
|
});
|
|
1036
1038
|
trackAddToCartFBQ({ lineItems });
|
|
1037
1039
|
}
|
|
1040
|
+
performanceAdapter?.addToCartEnd();
|
|
1038
1041
|
return resultCart;
|
|
1039
1042
|
},
|
|
1040
|
-
[client, locale, cartCookieAdapter, userAdapter, cart, withTrack]
|
|
1043
|
+
[client, locale, cartCookieAdapter, userAdapter, cart, withTrack, performanceAdapter]
|
|
1041
1044
|
);
|
|
1042
1045
|
return useSWRMutation("add-to-cart", addToCart, swrOptions);
|
|
1043
1046
|
}
|
|
@@ -2800,7 +2803,7 @@ function useAutoRemovePlusMemberInCart({
|
|
|
2800
2803
|
}
|
|
2801
2804
|
}, [cart, plus_annual_product, plus_monthly_product, profile, removeCartLines2]);
|
|
2802
2805
|
}
|
|
2803
|
-
function
|
|
2806
|
+
function usePlusMemberNeedAddToCart({
|
|
2804
2807
|
cart,
|
|
2805
2808
|
profile
|
|
2806
2809
|
}) {
|
|
@@ -3096,6 +3099,6 @@ function clearGeoLocationCache(cacheKey = "geoLocation") {
|
|
|
3096
3099
|
}
|
|
3097
3100
|
}
|
|
3098
3101
|
|
|
3099
|
-
export { BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, DeliveryPlusType, MAIN_PRODUCT_CODE, OrderBasePriceType, OrderDiscountType, PLUS_MEMBER_TYPE, PlusMemberContext, PlusMemberMode, PlusMemberProvider, PriceBasePriceType, PriceDiscountType, RuleType, SCRIPT_CODE_AMOUNT_KEY, ShippingMethodMode, SpendMoneyType, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, normalizeAddToCartLines, preCheck, safeParse, useAddCartLines,
|
|
3102
|
+
export { BuyRuleType, CODE_AMOUNT_KEY, CUSTOMER_ATTRIBUTE_KEY, CUSTOMER_SCRIPT_GIFT_KEY, DeliveryPlusType, MAIN_PRODUCT_CODE, OrderBasePriceType, OrderDiscountType, PLUS_MEMBER_TYPE, PlusMemberContext, PlusMemberMode, PlusMemberProvider, PriceBasePriceType, PriceDiscountType, RuleType, SCRIPT_CODE_AMOUNT_KEY, ShippingMethodMode, SpendMoneyType, checkAttributesUpdateNeeded, clearGeoLocationCache, createMockCartFromLines, currencyCodeMapping, defaultSWRMutationConfiguration, formatFunctionAutoFreeGift, formatScriptAutoFreeGift, getCachedGeoLocation, getDiscountEnvAttributeValue, getMatchedMainProductSubTotal, getQuery, getReferralAttributes, normalizeAddToCartLines, preCheck, safeParse, useAddCartLines, useAddToCart, useAllBlogs, useAllCollections, useAllProducts, useApplyCartCodes, useArticle, useArticles, useArticlesInBlog, useAutoRemovePlusMemberInCart, useBlog, useBuyNow, useCalcAutoFreeGift, useCalcGiftsFromLines, useCalcOrderDiscount, useCartAttributes, useCartItemQuantityLimit, useCollection, useCollections, useCreateCart, useExposure, useGeoLocation, useHasPlusMemberInCart, useIntersection, usePlusAnnualProductVariant, usePlusMemberCheckoutCustomAttributes, usePlusMemberContext, usePlusMemberDeliveryCodes, usePlusMemberItemCustomAttributes, usePlusMemberNeedAddToCart, usePlusMonthlyProductVariant, usePrice, useProduct, useProductUrl, useProductsByHandles, useRemoveCartCodes, useRemoveCartLines, useReplaceCartPlusMember, useScriptAutoFreeGift, useSearch, useSelectedOptions, useShippingMethodAvailableCheck, useShippingMethods, useSite, useUpdateCartAttributes, useUpdateCartLines, useUpdateLineCodeAmountAttributes, useUpdatePlusMemberDeliveryOptions, useUpdateVariantQuery, useVariant, useVariantMedia };
|
|
3100
3103
|
//# sourceMappingURL=index.mjs.map
|
|
3101
3104
|
//# sourceMappingURL=index.mjs.map
|