@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.mjs
CHANGED
|
@@ -119,7 +119,7 @@ function normalizeAddToCartLines(lines) {
|
|
|
119
119
|
customAttributes: line.attributes || [],
|
|
120
120
|
variant: {
|
|
121
121
|
id: variant.id,
|
|
122
|
-
price:
|
|
122
|
+
price: finalPrice,
|
|
123
123
|
listPrice: variant.compareAtPrice?.amount ? Number(variant.compareAtPrice.amount) : 0,
|
|
124
124
|
sku: variant.sku || "",
|
|
125
125
|
name: variant.title || "",
|
|
@@ -150,7 +150,7 @@ function createMockCartFromLines(lines, existingCart) {
|
|
|
150
150
|
const normalizedLines = normalizeAddToCartLines(lines);
|
|
151
151
|
const subtotalPrice = normalizedLines.reduce((sum, line) => sum + line.subtotalAmount, 0);
|
|
152
152
|
const totalPrice = normalizedLines.reduce((sum, line) => sum + line.totalAmount, 0);
|
|
153
|
-
console.log("lines
|
|
153
|
+
console.log("lines createMockCartFromLines4444", normalizedLines, lines);
|
|
154
154
|
const currency = lines[0]?.variant?.price?.currencyCode;
|
|
155
155
|
return {
|
|
156
156
|
id: existingCart?.id || "temp-cart-id",
|
|
@@ -397,6 +397,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
397
397
|
const effectiveCart = useMemo(() => {
|
|
398
398
|
return cart;
|
|
399
399
|
}, [lines, cart]);
|
|
400
|
+
console.log("effectiveCart useCalcAutoFreeGift", effectiveCart);
|
|
400
401
|
const { activeCampaign, subtotal } = useMemo(() => {
|
|
401
402
|
for (const campaign of autoFreeGiftConfig) {
|
|
402
403
|
const { rule_conditions = [], rule_result } = campaign;
|
|
@@ -412,6 +413,7 @@ var useCalcAutoFreeGift = (cart, autoFreeGiftConfig, customer, lines) => {
|
|
|
412
413
|
all_store_variant: spend_get_reward.main_product?.all_store_variant || false
|
|
413
414
|
}
|
|
414
415
|
);
|
|
416
|
+
console.log("matchedSubtotal useCalcAutoFreeGift", matchedSubtotal);
|
|
415
417
|
if (matchedSubtotal > 0) {
|
|
416
418
|
return { activeCampaign: campaign, subtotal: matchedSubtotal };
|
|
417
419
|
}
|
|
@@ -961,29 +963,22 @@ var useUpdateLineCodeAmountAttributes = ({
|
|
|
961
963
|
}).filter(
|
|
962
964
|
({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
|
|
963
965
|
).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
|
|
966
|
+
let lineId = line.id;
|
|
967
|
+
let attributes = line.customAttributes || [];
|
|
968
|
+
if (attrNeedDelete.length) {
|
|
969
|
+
attributes = attributes.filter(
|
|
970
|
+
(attr) => !attrNeedDelete.includes(attr.key)
|
|
971
|
+
);
|
|
972
|
+
}
|
|
964
973
|
if (attrNeedUpdate.length) {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
...line.customAttributes?.filter(
|
|
969
|
-
(attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
|
|
970
|
-
) || [],
|
|
971
|
-
...attrNeedUpdate
|
|
972
|
-
]
|
|
973
|
-
};
|
|
974
|
-
} else if (attrNeedDelete.length) {
|
|
975
|
-
return {
|
|
976
|
-
id: line.id,
|
|
977
|
-
attributes: line.customAttributes?.filter(
|
|
978
|
-
(attr) => !attrNeedDelete.includes(attr.key)
|
|
979
|
-
) || []
|
|
980
|
-
};
|
|
981
|
-
} else {
|
|
982
|
-
return {
|
|
983
|
-
id: line.id,
|
|
984
|
-
attributes: line.customAttributes || []
|
|
985
|
-
};
|
|
974
|
+
attributes = attributes.filter(
|
|
975
|
+
(attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
|
|
976
|
+
).concat(attrNeedUpdate);
|
|
986
977
|
}
|
|
978
|
+
return {
|
|
979
|
+
id: lineId,
|
|
980
|
+
attributes
|
|
981
|
+
};
|
|
987
982
|
}),
|
|
988
983
|
[cart?.lineItems, mainProductDiscountCodes]
|
|
989
984
|
);
|