@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/index.js
CHANGED
|
@@ -166,7 +166,7 @@ function normalizeAddToCartLines(lines) {
|
|
|
166
166
|
customAttributes: line.attributes || [],
|
|
167
167
|
variant: {
|
|
168
168
|
id: variant.id,
|
|
169
|
-
price:
|
|
169
|
+
price: finalPrice,
|
|
170
170
|
listPrice: variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : 0,
|
|
171
171
|
sku: variant.sku || "",
|
|
172
172
|
name: variant.title || "",
|
|
@@ -197,7 +197,7 @@ function createMockCartFromLines(lines, existingCart) {
|
|
|
197
197
|
const normalizedLines = normalizeAddToCartLines(lines);
|
|
198
198
|
const subtotalPrice = normalizedLines.reduce((sum, line) => sum + line.subtotalAmount, 0);
|
|
199
199
|
const totalPrice = normalizedLines.reduce((sum, line) => sum + line.totalAmount, 0);
|
|
200
|
-
console.log("lines
|
|
200
|
+
console.log("lines createMockCartFromLines4444", normalizedLines, lines);
|
|
201
201
|
const currency = lines[0]?.variant?.price?.currencyCode;
|
|
202
202
|
return {
|
|
203
203
|
id: existingCart?.id || "temp-cart-id",
|
|
@@ -447,6 +447,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
447
447
|
}
|
|
448
448
|
return cart;
|
|
449
449
|
}, [lines, cart]);
|
|
450
|
+
console.log("effectiveCart useCalcAutoFreeGift", effectiveCart);
|
|
450
451
|
const { activeCampaign, subtotal } = react.useMemo(() => {
|
|
451
452
|
for (const campaign of autoFreeGiftConfig) {
|
|
452
453
|
const { rule_conditions = [], rule_result } = campaign;
|
|
@@ -462,6 +463,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
462
463
|
all_store_variant: spend_get_reward.main_product?.all_store_variant || false
|
|
463
464
|
}
|
|
464
465
|
);
|
|
466
|
+
console.log("matchedSubtotal useCalcAutoFreeGift", matchedSubtotal);
|
|
465
467
|
if (matchedSubtotal > 0) {
|
|
466
468
|
return { activeCampaign: campaign, subtotal: matchedSubtotal };
|
|
467
469
|
}
|
|
@@ -1735,29 +1737,22 @@ var useUpdateLineCodeAmountAttributes = ({
|
|
|
1735
1737
|
}).filter(
|
|
1736
1738
|
({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
|
|
1737
1739
|
).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
|
|
1740
|
+
let lineId = line.id;
|
|
1741
|
+
let attributes = line.customAttributes || [];
|
|
1742
|
+
if (attrNeedDelete.length) {
|
|
1743
|
+
attributes = attributes.filter(
|
|
1744
|
+
(attr) => !attrNeedDelete.includes(attr.key)
|
|
1745
|
+
);
|
|
1746
|
+
}
|
|
1738
1747
|
if (attrNeedUpdate.length) {
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
...line.customAttributes?.filter(
|
|
1743
|
-
(attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
|
|
1744
|
-
) || [],
|
|
1745
|
-
...attrNeedUpdate
|
|
1746
|
-
]
|
|
1747
|
-
};
|
|
1748
|
-
} else if (attrNeedDelete.length) {
|
|
1749
|
-
return {
|
|
1750
|
-
id: line.id,
|
|
1751
|
-
attributes: line.customAttributes?.filter(
|
|
1752
|
-
(attr) => !attrNeedDelete.includes(attr.key)
|
|
1753
|
-
) || []
|
|
1754
|
-
};
|
|
1755
|
-
} else {
|
|
1756
|
-
return {
|
|
1757
|
-
id: line.id,
|
|
1758
|
-
attributes: line.customAttributes || []
|
|
1759
|
-
};
|
|
1748
|
+
attributes = attributes.filter(
|
|
1749
|
+
(attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
|
|
1750
|
+
).concat(attrNeedUpdate);
|
|
1760
1751
|
}
|
|
1752
|
+
return {
|
|
1753
|
+
id: lineId,
|
|
1754
|
+
attributes
|
|
1755
|
+
};
|
|
1761
1756
|
}),
|
|
1762
1757
|
[cart?.lineItems, mainProductDiscountCodes]
|
|
1763
1758
|
);
|