@anker-in/shopify-react 0.1.1-beta.10 → 0.1.1-beta.12
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 +24 -53
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +24 -53
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/{index-Dwc-_zEo.d.ts → index-BOsx-Rx3.d.ts} +1 -1
- package/dist/{index-CwP6qHUo.d.mts → index-D5VVTzBT.d.mts} +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +24 -53
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -53
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.js +12 -1
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +12 -1
- package/dist/provider/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1416,7 +1416,7 @@ var useCartAttributes = ({
|
|
|
1416
1416
|
return "new_user_login";
|
|
1417
1417
|
}, [customer]);
|
|
1418
1418
|
const memberAttributes = useMemo(() => {
|
|
1419
|
-
|
|
1419
|
+
const attributes = [
|
|
1420
1420
|
{
|
|
1421
1421
|
key: "_token",
|
|
1422
1422
|
value: profile?.token
|
|
@@ -1435,8 +1435,19 @@ var useCartAttributes = ({
|
|
|
1435
1435
|
{
|
|
1436
1436
|
key: "_is_login",
|
|
1437
1437
|
value: profile?.token ? "true" : "false"
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
key: "_last_url",
|
|
1441
|
+
value: typeof window !== "undefined" ? window.location.origin + window.location.pathname : ""
|
|
1438
1442
|
}
|
|
1439
1443
|
];
|
|
1444
|
+
if (profile?.token) {
|
|
1445
|
+
attributes.push({
|
|
1446
|
+
key: "_login_user",
|
|
1447
|
+
value: "1"
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
return attributes;
|
|
1440
1451
|
}, [profile?.memberType, profile?.token, userType, hasPlusMember]);
|
|
1441
1452
|
const functionAttributes = useMemo(() => {
|
|
1442
1453
|
const hasFunctionEnvAttribute = cart?.lineItems.some(
|
|
@@ -2652,21 +2663,22 @@ function useUpdateCartDeliveryOptions(mutate, metafieldIdentifiers, options) {
|
|
|
2652
2663
|
var useUpdatePlusMemberDeliveryOptions = ({
|
|
2653
2664
|
options
|
|
2654
2665
|
}) => {
|
|
2655
|
-
const { cart, mutateCart
|
|
2666
|
+
const { cart: cartContextData, mutateCart, metafieldIdentifiers } = useCartContext();
|
|
2656
2667
|
const { trigger: updateCartDeliveryOptions2, isMutating } = useUpdateCartDeliveryOptions(
|
|
2657
|
-
|
|
2668
|
+
mutateCart,
|
|
2658
2669
|
metafieldIdentifiers
|
|
2659
2670
|
);
|
|
2660
2671
|
const handler = useCallback(
|
|
2661
2672
|
async (_, { arg }) => {
|
|
2673
|
+
const currentCart = arg?.cart || cartContextData;
|
|
2662
2674
|
const { deliveryData } = arg;
|
|
2663
|
-
const firstDeliveryGroup =
|
|
2675
|
+
const firstDeliveryGroup = currentCart?.deliveryGroups?.[0];
|
|
2664
2676
|
const deliveryGroupId = firstDeliveryGroup?.id;
|
|
2665
2677
|
const selectedOptionCode = deliveryData?.deliveryCustomData?.selected_delivery_option?.code;
|
|
2666
2678
|
if (!deliveryGroupId || !selectedOptionCode || selectedOptionCode === firstDeliveryGroup?.selectedDeliveryOption?.code) {
|
|
2667
2679
|
return null;
|
|
2668
2680
|
}
|
|
2669
|
-
const deliveryGroup =
|
|
2681
|
+
const deliveryGroup = currentCart?.deliveryGroups?.find((group) => group?.id === deliveryGroupId);
|
|
2670
2682
|
const matchedOption = deliveryGroup?.deliveryOptions?.find(
|
|
2671
2683
|
(option) => option?.code === selectedOptionCode
|
|
2672
2684
|
);
|
|
@@ -2680,14 +2692,15 @@ var useUpdatePlusMemberDeliveryOptions = ({
|
|
|
2680
2692
|
}
|
|
2681
2693
|
];
|
|
2682
2694
|
const updatedCart = await updateCartDeliveryOptions2({
|
|
2683
|
-
selectedDeliveryOptions: deliveryOptions
|
|
2695
|
+
selectedDeliveryOptions: deliveryOptions,
|
|
2696
|
+
cartId: currentCart?.id
|
|
2684
2697
|
});
|
|
2685
|
-
if (updatedCart &&
|
|
2686
|
-
|
|
2698
|
+
if (updatedCart && mutateCart) {
|
|
2699
|
+
mutateCart(updatedCart);
|
|
2687
2700
|
}
|
|
2688
2701
|
return updatedCart;
|
|
2689
2702
|
},
|
|
2690
|
-
[
|
|
2703
|
+
[cartContextData, updateCartDeliveryOptions2, mutateCart]
|
|
2691
2704
|
);
|
|
2692
2705
|
return useSWRMutation("update-cart-delivery-options", handler, options);
|
|
2693
2706
|
};
|
|
@@ -2710,48 +2723,12 @@ var usePlusMemberCheckoutCustomAttributes = ({
|
|
|
2710
2723
|
deliveryData,
|
|
2711
2724
|
product,
|
|
2712
2725
|
variant,
|
|
2713
|
-
customer,
|
|
2714
2726
|
isShowShippingBenefits
|
|
2715
2727
|
}) => {
|
|
2716
2728
|
const { deliveryCustomData } = deliveryData || {};
|
|
2717
2729
|
const { profile } = usePlusMemberContext();
|
|
2718
|
-
const userType = useMemo(() => {
|
|
2719
|
-
const customerInfo = customer;
|
|
2720
|
-
if (!customerInfo) {
|
|
2721
|
-
return "new_user_unlogin";
|
|
2722
|
-
}
|
|
2723
|
-
if (customer) {
|
|
2724
|
-
const { orders = {} } = customer;
|
|
2725
|
-
const edgesLength = orders?.edges?.length;
|
|
2726
|
-
if (edgesLength === 1) {
|
|
2727
|
-
return "old_user_orders_once";
|
|
2728
|
-
} else if (edgesLength && edgesLength > 1) {
|
|
2729
|
-
return "old_user_orders_twice";
|
|
2730
|
-
}
|
|
2731
|
-
}
|
|
2732
|
-
return "new_user_login";
|
|
2733
|
-
}, [customer]);
|
|
2734
2730
|
return useMemo(() => {
|
|
2735
|
-
const checkoutCustomAttributes = [
|
|
2736
|
-
{
|
|
2737
|
-
key: "_token",
|
|
2738
|
-
value: profile?.token || ""
|
|
2739
|
-
},
|
|
2740
|
-
{
|
|
2741
|
-
key: "_last_url",
|
|
2742
|
-
value: typeof window !== "undefined" ? window.location.origin + window.location.pathname : ""
|
|
2743
|
-
},
|
|
2744
|
-
{
|
|
2745
|
-
key: "_user_type",
|
|
2746
|
-
value: userType
|
|
2747
|
-
}
|
|
2748
|
-
];
|
|
2749
|
-
if (profile) {
|
|
2750
|
-
checkoutCustomAttributes.push({
|
|
2751
|
-
key: "_login_user",
|
|
2752
|
-
value: "1"
|
|
2753
|
-
});
|
|
2754
|
-
}
|
|
2731
|
+
const checkoutCustomAttributes = [];
|
|
2755
2732
|
if (deliveryCustomData) {
|
|
2756
2733
|
checkoutCustomAttributes.push({
|
|
2757
2734
|
key: "_checkout_delivery_custom",
|
|
@@ -2761,12 +2738,6 @@ var usePlusMemberCheckoutCustomAttributes = ({
|
|
|
2761
2738
|
})
|
|
2762
2739
|
});
|
|
2763
2740
|
}
|
|
2764
|
-
if (variant?.metafields?.presell) {
|
|
2765
|
-
checkoutCustomAttributes.push({
|
|
2766
|
-
key: "_presale",
|
|
2767
|
-
value: "true"
|
|
2768
|
-
});
|
|
2769
|
-
}
|
|
2770
2741
|
if (isShowShippingBenefits && !isShowShippingBenefits({ variant, product, setting: {} })) {
|
|
2771
2742
|
checkoutCustomAttributes.push({
|
|
2772
2743
|
key: "_hide_shipping",
|
|
@@ -2774,7 +2745,7 @@ var usePlusMemberCheckoutCustomAttributes = ({
|
|
|
2774
2745
|
});
|
|
2775
2746
|
}
|
|
2776
2747
|
return checkoutCustomAttributes;
|
|
2777
|
-
}, [deliveryCustomData, product, profile,
|
|
2748
|
+
}, [deliveryCustomData, product, profile, variant, isShowShippingBenefits]);
|
|
2778
2749
|
};
|
|
2779
2750
|
function useAutoRemovePlusMemberInCart({
|
|
2780
2751
|
cart,
|