@anker-in/shopify-react 0.1.1-beta.23 → 0.1.1-beta.25
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 +18 -23
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +18 -23
- package/dist/hooks/index.mjs.map +1 -1
- package/dist/index.js +18 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -23
- package/dist/index.mjs.map +1 -1
- package/dist/provider/index.js +18 -23
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/index.mjs +18 -23
- package/dist/provider/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/hooks/index.mjs
CHANGED
|
@@ -86,7 +86,7 @@ function normalizeAddToCartLines(lines) {
|
|
|
86
86
|
customAttributes: line.attributes || [],
|
|
87
87
|
variant: {
|
|
88
88
|
id: variant.id,
|
|
89
|
-
price:
|
|
89
|
+
price: finalPrice,
|
|
90
90
|
listPrice: variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : 0,
|
|
91
91
|
sku: variant.sku || "",
|
|
92
92
|
name: variant.title || "",
|
|
@@ -117,7 +117,7 @@ function createMockCartFromLines(lines, existingCart) {
|
|
|
117
117
|
const normalizedLines = normalizeAddToCartLines(lines);
|
|
118
118
|
const subtotalPrice = normalizedLines.reduce((sum, line) => sum + line.subtotalAmount, 0);
|
|
119
119
|
const totalPrice = normalizedLines.reduce((sum, line) => sum + line.totalAmount, 0);
|
|
120
|
-
console.log("lines
|
|
120
|
+
console.log("lines createMockCartFromLines4444", normalizedLines, lines);
|
|
121
121
|
const currency = lines[0]?.variant?.price?.currencyCode;
|
|
122
122
|
return {
|
|
123
123
|
id: existingCart?.id || "temp-cart-id",
|
|
@@ -367,6 +367,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
367
367
|
}
|
|
368
368
|
return cart;
|
|
369
369
|
}, [lines, cart]);
|
|
370
|
+
console.log("effectiveCart useCalcAutoFreeGift", effectiveCart);
|
|
370
371
|
const { activeCampaign, subtotal } = useMemo(() => {
|
|
371
372
|
for (const campaign of autoFreeGiftConfig) {
|
|
372
373
|
const { rule_conditions = [], rule_result } = campaign;
|
|
@@ -382,6 +383,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
382
383
|
all_store_variant: spend_get_reward.main_product?.all_store_variant || false
|
|
383
384
|
}
|
|
384
385
|
);
|
|
386
|
+
console.log("matchedSubtotal useCalcAutoFreeGift", matchedSubtotal);
|
|
385
387
|
if (matchedSubtotal > 0) {
|
|
386
388
|
return { activeCampaign: campaign, subtotal: matchedSubtotal };
|
|
387
389
|
}
|
|
@@ -1630,29 +1632,22 @@ var useUpdateLineCodeAmountAttributes = ({
|
|
|
1630
1632
|
}).filter(
|
|
1631
1633
|
({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
|
|
1632
1634
|
).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
|
|
1635
|
+
let lineId = line.id;
|
|
1636
|
+
let attributes = line.customAttributes || [];
|
|
1637
|
+
if (attrNeedDelete.length) {
|
|
1638
|
+
attributes = attributes.filter(
|
|
1639
|
+
(attr) => !attrNeedDelete.includes(attr.key)
|
|
1640
|
+
);
|
|
1641
|
+
}
|
|
1633
1642
|
if (attrNeedUpdate.length) {
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
...line.customAttributes?.filter(
|
|
1638
|
-
(attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
|
|
1639
|
-
) || [],
|
|
1640
|
-
...attrNeedUpdate
|
|
1641
|
-
]
|
|
1642
|
-
};
|
|
1643
|
-
} else if (attrNeedDelete.length) {
|
|
1644
|
-
return {
|
|
1645
|
-
id: line.id,
|
|
1646
|
-
attributes: line.customAttributes?.filter(
|
|
1647
|
-
(attr) => !attrNeedDelete.includes(attr.key)
|
|
1648
|
-
) || []
|
|
1649
|
-
};
|
|
1650
|
-
} else {
|
|
1651
|
-
return {
|
|
1652
|
-
id: line.id,
|
|
1653
|
-
attributes: line.customAttributes || []
|
|
1654
|
-
};
|
|
1643
|
+
attributes = attributes.filter(
|
|
1644
|
+
(attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
|
|
1645
|
+
).concat(attrNeedUpdate);
|
|
1655
1646
|
}
|
|
1647
|
+
return {
|
|
1648
|
+
id: lineId,
|
|
1649
|
+
attributes
|
|
1650
|
+
};
|
|
1656
1651
|
}),
|
|
1657
1652
|
[cart?.lineItems, mainProductDiscountCodes]
|
|
1658
1653
|
);
|