@anker-in/shopify-react 0.1.1-beta.40 → 0.1.1-beta.42
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 +66 -28
- package/dist/hooks/index.d.ts +66 -28
- package/dist/hooks/index.js +183 -132
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +182 -131
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +188 -133
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +187 -132
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.d.mts +1 -1
- package/dist/provider/index.d.ts +1 -1
- package/dist/provider/index.js +21 -11
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +21 -11
- package/dist/provider/index.mjs.map +1 -1
- package/dist/{types-BSsb8OPm.d.mts → types-DntkHhf8.d.mts} +8 -5
- package/dist/{types-BSsb8OPm.d.ts → types-DntkHhf8.d.ts} +8 -5
- package/package.json +3 -3
package/dist/provider/index.mjs
CHANGED
|
@@ -702,24 +702,31 @@ var useScriptAutoFreeGift = ({
|
|
|
702
702
|
giftProductsResult: finalGiftProductsResult
|
|
703
703
|
};
|
|
704
704
|
};
|
|
705
|
-
function useUpdateCartAttributes(
|
|
705
|
+
function useUpdateCartAttributes({
|
|
706
|
+
mutate,
|
|
707
|
+
metafieldIdentifiers,
|
|
708
|
+
disabled = false,
|
|
709
|
+
swrOptions
|
|
710
|
+
}) {
|
|
706
711
|
const { client, locale, cartCookieAdapter } = useShopify();
|
|
707
712
|
const updateAttributes = useCallback(
|
|
708
713
|
async (_key, { arg }) => {
|
|
714
|
+
if (disabled || !cartCookieAdapter?.getCartId(locale)) {
|
|
715
|
+
return void 0;
|
|
716
|
+
}
|
|
709
717
|
const updatedCart = await updateCartAttributes(client, {
|
|
710
718
|
...arg,
|
|
711
719
|
metafieldIdentifiers,
|
|
712
720
|
cookieAdapter: cartCookieAdapter
|
|
713
721
|
});
|
|
714
|
-
console.log("useUpdateCartAttributes updatedCart", updatedCart);
|
|
715
722
|
if (updatedCart) {
|
|
716
723
|
mutate(updatedCart);
|
|
717
724
|
}
|
|
718
725
|
return updatedCart;
|
|
719
726
|
},
|
|
720
|
-
[client, locale, cartCookieAdapter, mutate, metafieldIdentifiers]
|
|
727
|
+
[client, locale, cartCookieAdapter, mutate, metafieldIdentifiers, disabled]
|
|
721
728
|
);
|
|
722
|
-
return useSWRMutation8("update-cart-attributes", updateAttributes,
|
|
729
|
+
return useSWRMutation8("update-cart-attributes", updateAttributes, swrOptions);
|
|
723
730
|
}
|
|
724
731
|
function useHasPlusMemberInCart({
|
|
725
732
|
memberSetting,
|
|
@@ -847,7 +854,7 @@ var useCartAttributes = ({
|
|
|
847
854
|
})
|
|
848
855
|
}
|
|
849
856
|
] : [];
|
|
850
|
-
}, [cart]);
|
|
857
|
+
}, [cart, customer]);
|
|
851
858
|
const presellAttributes = useMemo(() => {
|
|
852
859
|
return [
|
|
853
860
|
{
|
|
@@ -911,9 +918,7 @@ var useCartAttributes = ({
|
|
|
911
918
|
"_play_mode_id",
|
|
912
919
|
"_popup"
|
|
913
920
|
];
|
|
914
|
-
return cart?.customAttributes?.filter(
|
|
915
|
-
(item) => !commonAttributeKeys.includes(item.key)
|
|
916
|
-
) || [];
|
|
921
|
+
return cart?.customAttributes?.filter((item) => !commonAttributeKeys.includes(item.key)) || [];
|
|
917
922
|
}, [cart]);
|
|
918
923
|
return useMemo(
|
|
919
924
|
() => ({
|
|
@@ -1075,8 +1080,9 @@ var createInitialValue = () => ({
|
|
|
1075
1080
|
tddCoupon: void 0,
|
|
1076
1081
|
isLoadingCoupon: false
|
|
1077
1082
|
},
|
|
1078
|
-
|
|
1079
|
-
|
|
1083
|
+
selectedPlusMemberVariant: void 0,
|
|
1084
|
+
monthlyVariant: void 0,
|
|
1085
|
+
annualVariant: void 0,
|
|
1080
1086
|
showPlusMemberBenefit: false,
|
|
1081
1087
|
setShowPlusMemberBenefit: () => {
|
|
1082
1088
|
},
|
|
@@ -1129,7 +1135,11 @@ function CartProvider({
|
|
|
1129
1135
|
refreshDeps: [locale]
|
|
1130
1136
|
}
|
|
1131
1137
|
);
|
|
1132
|
-
const { trigger: updateAttributes } = useUpdateCartAttributes(
|
|
1138
|
+
const { trigger: updateAttributes } = useUpdateCartAttributes({
|
|
1139
|
+
mutate: mutateCart,
|
|
1140
|
+
metafieldIdentifiers,
|
|
1141
|
+
disabled: isCartLoading
|
|
1142
|
+
});
|
|
1133
1143
|
const { attributes } = useCartAttributes({ profile, customer, cart, memberSetting });
|
|
1134
1144
|
useRequest(
|
|
1135
1145
|
() => {
|