@anker-in/shopify-react 0.1.1-beta.18 → 0.1.1-beta.19
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.js +49 -34
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +49 -34
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.js +55 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -35
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.js +50 -31
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +50 -31
- package/dist/provider/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/provider/index.mjs
CHANGED
|
@@ -477,18 +477,24 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
477
477
|
}
|
|
478
478
|
return true;
|
|
479
479
|
}, [giftHandles]);
|
|
480
|
-
const { data: giftProductsResult } = useSWR(
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
480
|
+
const { data: giftProductsResult } = useSWR(
|
|
481
|
+
shouldFetch ? giftHandles : null,
|
|
482
|
+
async () => {
|
|
483
|
+
const res = await getProductsByHandles(client, {
|
|
484
|
+
handles: giftHandles,
|
|
485
|
+
locale
|
|
486
|
+
});
|
|
487
|
+
const result = Array.isArray(res) ? res : [];
|
|
488
|
+
giftProductsCache.current = {
|
|
489
|
+
data: result,
|
|
490
|
+
giftHandles: [...giftHandles]
|
|
491
|
+
};
|
|
492
|
+
return result;
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
revalidateOnFocus: false
|
|
496
|
+
}
|
|
497
|
+
);
|
|
492
498
|
const finalGiftProductsResult = useMemo(() => {
|
|
493
499
|
if (giftProductsCache.current && !shouldFetch) {
|
|
494
500
|
return giftProductsCache.current.data || void 0;
|
|
@@ -541,12 +547,14 @@ var useScriptAutoFreeGift = ({
|
|
|
541
547
|
upgrade_multiple2 = 1.2;
|
|
542
548
|
upgrade_value2 = 40;
|
|
543
549
|
}
|
|
544
|
-
effectiveCart?.lineItems?.forEach(
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
+
effectiveCart?.lineItems?.forEach(
|
|
551
|
+
({ customAttributes }) => {
|
|
552
|
+
customAttributes?.forEach(({ key, value }) => {
|
|
553
|
+
if (key === "_amount_upgrade_multiple") upgrade_multiple2 = Number(value) || 1;
|
|
554
|
+
if (key === "_amount_upgrade_value") upgrade_value2 = Number(value) || 0;
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
);
|
|
550
558
|
return [upgrade_multiple2, upgrade_value2];
|
|
551
559
|
}, [effectiveCart?.lineItems, points_subscribe]);
|
|
552
560
|
const breakpoints = useMemo(() => {
|
|
@@ -611,18 +619,24 @@ var useScriptAutoFreeGift = ({
|
|
|
611
619
|
const nextLevel = levelIndex > 0 ? sortedLevels[levelIndex - 1] ?? null : null;
|
|
612
620
|
return [currentLevel, nextLevel];
|
|
613
621
|
}, [breakpoints, involvedSubTotal, involvedLines.length]);
|
|
614
|
-
const { data: giftProductsResult } = useSWR(
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
622
|
+
const { data: giftProductsResult } = useSWR(
|
|
623
|
+
shouldFetch ? giftHandles : null,
|
|
624
|
+
async () => {
|
|
625
|
+
const res = await getProductsByHandles(client, {
|
|
626
|
+
handles: giftHandles,
|
|
627
|
+
locale
|
|
628
|
+
});
|
|
629
|
+
const result = Array.isArray(res) ? res : [];
|
|
630
|
+
giftProductsCache.current = {
|
|
631
|
+
data: result,
|
|
632
|
+
giftHandles: [...giftHandles]
|
|
633
|
+
};
|
|
634
|
+
return result;
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
revalidateOnFocus: false
|
|
638
|
+
}
|
|
639
|
+
);
|
|
626
640
|
const finalGiftProductsResult = useMemo(() => {
|
|
627
641
|
if (giftProductsCache.current && !shouldFetch) {
|
|
628
642
|
return giftProductsCache.current.data || void 0;
|
|
@@ -1091,7 +1105,12 @@ function CartProvider({
|
|
|
1091
1105
|
const { attributes } = useCartAttributes({ profile, customer, cart, memberSetting });
|
|
1092
1106
|
useRequest(
|
|
1093
1107
|
() => {
|
|
1094
|
-
const newAttributes = [...attributes
|
|
1108
|
+
const newAttributes = [...attributes];
|
|
1109
|
+
customAttributes.forEach((item) => {
|
|
1110
|
+
if (item.value && !newAttributes.some((attr) => attr.key === item.key)) {
|
|
1111
|
+
newAttributes.push(item);
|
|
1112
|
+
}
|
|
1113
|
+
});
|
|
1095
1114
|
const needUpdate = cart && checkAttributesUpdateNeeded(
|
|
1096
1115
|
cart.customAttributes,
|
|
1097
1116
|
newAttributes,
|