@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/provider/index.js
CHANGED
|
@@ -128,7 +128,7 @@ function normalizeAddToCartLines(lines) {
|
|
|
128
128
|
customAttributes: line.attributes || [],
|
|
129
129
|
variant: {
|
|
130
130
|
id: variant.id,
|
|
131
|
-
price:
|
|
131
|
+
price: finalPrice,
|
|
132
132
|
listPrice: variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : 0,
|
|
133
133
|
sku: variant.sku || "",
|
|
134
134
|
name: variant.title || "",
|
|
@@ -159,7 +159,7 @@ function createMockCartFromLines(lines, existingCart) {
|
|
|
159
159
|
const normalizedLines = normalizeAddToCartLines(lines);
|
|
160
160
|
const subtotalPrice = normalizedLines.reduce((sum, line) => sum + line.subtotalAmount, 0);
|
|
161
161
|
const totalPrice = normalizedLines.reduce((sum, line) => sum + line.totalAmount, 0);
|
|
162
|
-
console.log("lines
|
|
162
|
+
console.log("lines createMockCartFromLines4444", normalizedLines, lines);
|
|
163
163
|
const currency = lines[0]?.variant?.price?.currencyCode;
|
|
164
164
|
return {
|
|
165
165
|
id: existingCart?.id || "temp-cart-id",
|
|
@@ -406,6 +406,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
406
406
|
const effectiveCart = react.useMemo(() => {
|
|
407
407
|
return cart;
|
|
408
408
|
}, [lines, cart]);
|
|
409
|
+
console.log("effectiveCart useCalcAutoFreeGift", effectiveCart);
|
|
409
410
|
const { activeCampaign, subtotal } = react.useMemo(() => {
|
|
410
411
|
for (const campaign of autoFreeGiftConfig) {
|
|
411
412
|
const { rule_conditions = [], rule_result } = campaign;
|
|
@@ -421,6 +422,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
421
422
|
all_store_variant: spend_get_reward.main_product?.all_store_variant || false
|
|
422
423
|
}
|
|
423
424
|
);
|
|
425
|
+
console.log("matchedSubtotal useCalcAutoFreeGift", matchedSubtotal);
|
|
424
426
|
if (matchedSubtotal > 0) {
|
|
425
427
|
return { activeCampaign: campaign, subtotal: matchedSubtotal };
|
|
426
428
|
}
|
|
@@ -970,29 +972,22 @@ var useUpdateLineCodeAmountAttributes = ({
|
|
|
970
972
|
}).filter(
|
|
971
973
|
({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
|
|
972
974
|
).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
|
|
975
|
+
let lineId = line.id;
|
|
976
|
+
let attributes = line.customAttributes || [];
|
|
977
|
+
if (attrNeedDelete.length) {
|
|
978
|
+
attributes = attributes.filter(
|
|
979
|
+
(attr) => !attrNeedDelete.includes(attr.key)
|
|
980
|
+
);
|
|
981
|
+
}
|
|
973
982
|
if (attrNeedUpdate.length) {
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
...line.customAttributes?.filter(
|
|
978
|
-
(attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
|
|
979
|
-
) || [],
|
|
980
|
-
...attrNeedUpdate
|
|
981
|
-
]
|
|
982
|
-
};
|
|
983
|
-
} else if (attrNeedDelete.length) {
|
|
984
|
-
return {
|
|
985
|
-
id: line.id,
|
|
986
|
-
attributes: line.customAttributes?.filter(
|
|
987
|
-
(attr) => !attrNeedDelete.includes(attr.key)
|
|
988
|
-
) || []
|
|
989
|
-
};
|
|
990
|
-
} else {
|
|
991
|
-
return {
|
|
992
|
-
id: line.id,
|
|
993
|
-
attributes: line.customAttributes || []
|
|
994
|
-
};
|
|
983
|
+
attributes = attributes.filter(
|
|
984
|
+
(attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
|
|
985
|
+
).concat(attrNeedUpdate);
|
|
995
986
|
}
|
|
987
|
+
return {
|
|
988
|
+
id: lineId,
|
|
989
|
+
attributes
|
|
990
|
+
};
|
|
996
991
|
}),
|
|
997
992
|
[cart?.lineItems, mainProductDiscountCodes]
|
|
998
993
|
);
|