@anker-in/shopify-react 0.1.1-beta.11 → 0.1.1-beta.13
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 +2 -2
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.js +15 -11
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +15 -11
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/{index-BOsx-Rx3.d.ts → index-C77lIEQZ.d.ts} +2 -2
- package/dist/{index-D5VVTzBT.d.mts → index-CO_fgrFV.d.mts} +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +16 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -12
- 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 +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/dist/{types-CUv-lzQk.d.mts → types-DpxtE_nv.d.mts} +1 -4
- package/dist/{types-CUv-lzQk.d.ts → types-DpxtE_nv.d.ts} +1 -4
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -2662,22 +2662,25 @@ function useUpdateCartDeliveryOptions(mutate, metafieldIdentifiers, options) {
|
|
|
2662
2662
|
// src/hooks/member/plus/use-update-plus-member-delivery-options.ts
|
|
2663
2663
|
var useUpdatePlusMemberDeliveryOptions = ({
|
|
2664
2664
|
options
|
|
2665
|
-
}) => {
|
|
2666
|
-
const { cart, mutateCart
|
|
2667
|
-
const { trigger: updateCartDeliveryOptions2
|
|
2668
|
-
|
|
2665
|
+
} = {}) => {
|
|
2666
|
+
const { cart: cartContextData, mutateCart, metafieldIdentifiers } = useCartContext();
|
|
2667
|
+
const { trigger: updateCartDeliveryOptions2 } = useUpdateCartDeliveryOptions(
|
|
2668
|
+
mutateCart,
|
|
2669
2669
|
metafieldIdentifiers
|
|
2670
2670
|
);
|
|
2671
2671
|
const handler = useCallback(
|
|
2672
2672
|
async (_, { arg }) => {
|
|
2673
|
+
const currentCart = arg?.cart || cartContextData;
|
|
2673
2674
|
const { deliveryData } = arg;
|
|
2674
|
-
const firstDeliveryGroup =
|
|
2675
|
+
const firstDeliveryGroup = currentCart?.deliveryGroups?.[0];
|
|
2675
2676
|
const deliveryGroupId = firstDeliveryGroup?.id;
|
|
2676
|
-
const selectedOptionCode = deliveryData?.deliveryCustomData?.selected_delivery_option
|
|
2677
|
+
const selectedOptionCode = deliveryData?.deliveryCustomData?.selected_delivery_option;
|
|
2677
2678
|
if (!deliveryGroupId || !selectedOptionCode || selectedOptionCode === firstDeliveryGroup?.selectedDeliveryOption?.code) {
|
|
2678
2679
|
return null;
|
|
2679
2680
|
}
|
|
2680
|
-
const deliveryGroup =
|
|
2681
|
+
const deliveryGroup = currentCart?.deliveryGroups?.find(
|
|
2682
|
+
(group) => group?.id === deliveryGroupId
|
|
2683
|
+
);
|
|
2681
2684
|
const matchedOption = deliveryGroup?.deliveryOptions?.find(
|
|
2682
2685
|
(option) => option?.code === selectedOptionCode
|
|
2683
2686
|
);
|
|
@@ -2691,14 +2694,15 @@ var useUpdatePlusMemberDeliveryOptions = ({
|
|
|
2691
2694
|
}
|
|
2692
2695
|
];
|
|
2693
2696
|
const updatedCart = await updateCartDeliveryOptions2({
|
|
2694
|
-
selectedDeliveryOptions: deliveryOptions
|
|
2697
|
+
selectedDeliveryOptions: deliveryOptions,
|
|
2698
|
+
cartId: currentCart?.id
|
|
2695
2699
|
});
|
|
2696
|
-
if (updatedCart &&
|
|
2697
|
-
|
|
2700
|
+
if (updatedCart && mutateCart) {
|
|
2701
|
+
mutateCart(updatedCart);
|
|
2698
2702
|
}
|
|
2699
2703
|
return updatedCart;
|
|
2700
2704
|
},
|
|
2701
|
-
[
|
|
2705
|
+
[cartContextData, updateCartDeliveryOptions2, mutateCart]
|
|
2702
2706
|
);
|
|
2703
2707
|
return useSWRMutation("update-cart-delivery-options", handler, options);
|
|
2704
2708
|
};
|
|
@@ -3115,7 +3119,7 @@ function CartProvider({
|
|
|
3115
3119
|
useRequest(
|
|
3116
3120
|
() => {
|
|
3117
3121
|
const newAttributes = [...attributes, ...customAttributes];
|
|
3118
|
-
const needUpdate = cart &&
|
|
3122
|
+
const needUpdate = cart && checkAttributesUpdateNeeded(
|
|
3119
3123
|
cart.customAttributes,
|
|
3120
3124
|
newAttributes,
|
|
3121
3125
|
customAttributesNeedDelete
|