@artisan-commerce/analytics-web 0.2.0-canary.63 → 0.2.0-canary.64
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/CHANGELOG.md +8 -0
- package/dist/bundle.cjs.js +28 -5
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +28 -5
- package/dist/bundle.esm.js.map +1 -1
- package/dist/bundle.umd.js +28 -5
- package/dist/bundle.umd.js.map +1 -1
- package/package.json +5 -5
package/dist/bundle.esm.js
CHANGED
|
@@ -35,7 +35,7 @@ const getState$2 = () => {
|
|
|
35
35
|
|
|
36
36
|
var name = "@artisan-commerce/analytics-web";
|
|
37
37
|
var description = "Artisn commerce analytics web library";
|
|
38
|
-
var version = "0.2.0-canary.
|
|
38
|
+
var version = "0.2.0-canary.63";
|
|
39
39
|
var main = "./dist/bundle.cjs.js";
|
|
40
40
|
var module = "./dist/bundle.esm.js";
|
|
41
41
|
var types = "./dist/bundle.d.ts";
|
|
@@ -77,7 +77,7 @@ var dependencies = {
|
|
|
77
77
|
};
|
|
78
78
|
var devDependencies = {
|
|
79
79
|
"@artisan-commerce/products": "0.9.0-canary.40",
|
|
80
|
-
"@artisan-commerce/shopping-cart": "0.12.0-canary.
|
|
80
|
+
"@artisan-commerce/shopping-cart": "0.12.0-canary.60",
|
|
81
81
|
"@artisan-commerce/types": "0.14.0-canary.31"
|
|
82
82
|
};
|
|
83
83
|
var peerDependencies = {
|
|
@@ -1645,13 +1645,16 @@ const applyBenefits = (additionalInfo, benefits, shoppingCartTotals) => {
|
|
|
1645
1645
|
}
|
|
1646
1646
|
const benefitsValues = Object.values(benefits);
|
|
1647
1647
|
return benefitsValues.reduce((acc, benefit) => {
|
|
1648
|
-
if (benefit.type === "
|
|
1649
|
-
return
|
|
1648
|
+
if (benefit.type === "DISCOUNT_PERCENTAGE" && benefit.discountPercentage) {
|
|
1649
|
+
return applyBenefitByDiscountPercentage(benefit, acc, additionalInfo);
|
|
1650
|
+
}
|
|
1651
|
+
if (benefit.type === "DISCOUNT_FIXED" && benefit.discountFixed) {
|
|
1652
|
+
return applyBenefitByDiscountFixed(benefit, acc, additionalInfo);
|
|
1650
1653
|
}
|
|
1651
1654
|
return acc;
|
|
1652
1655
|
}, shoppingCartTotals);
|
|
1653
1656
|
};
|
|
1654
|
-
const
|
|
1657
|
+
const applyBenefitByDiscountPercentage = (benefit, shoppingCartTotals, additionalInfo) => {
|
|
1655
1658
|
const { subtotal, total: prevTotal } = shoppingCartTotals;
|
|
1656
1659
|
const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
|
|
1657
1660
|
const discountPercentage = benefit.discountPercentage * 0.01;
|
|
@@ -1674,6 +1677,26 @@ const applyBenefitByDiscount = (benefit, shoppingCartTotals, additionalInfo) =>
|
|
|
1674
1677
|
total: newTotal
|
|
1675
1678
|
});
|
|
1676
1679
|
};
|
|
1680
|
+
const applyBenefitByDiscountFixed = (benefit, shoppingCartTotals, additionalInfo) => {
|
|
1681
|
+
const { total: prevTotal } = shoppingCartTotals;
|
|
1682
|
+
const { totalDiscounts: prevTotalDiscounts } = shoppingCartTotals;
|
|
1683
|
+
const discountFixed = Number(benefit.discountFixed);
|
|
1684
|
+
if (typeof (additionalInfo == null ? void 0 : additionalInfo.copayment) !== "undefined") {
|
|
1685
|
+
const copayment = additionalInfo == null ? void 0 : additionalInfo.copayment;
|
|
1686
|
+
const newTotalDiscounts2 = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
|
|
1687
|
+
const newTotal2 = (copayment - discountFixed).toFixed(4);
|
|
1688
|
+
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|
|
1689
|
+
totalDiscounts: newTotalDiscounts2,
|
|
1690
|
+
total: Number(newTotal2)
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
const newTotalDiscounts = prevTotalDiscounts !== null ? prevTotalDiscounts + discountFixed : discountFixed;
|
|
1694
|
+
const newTotal = prevTotal - discountFixed;
|
|
1695
|
+
return __spreadProps$c$1(__spreadValues$g$1({}, shoppingCartTotals), {
|
|
1696
|
+
totalDiscounts: newTotalDiscounts,
|
|
1697
|
+
total: newTotal
|
|
1698
|
+
});
|
|
1699
|
+
};
|
|
1677
1700
|
|
|
1678
1701
|
const isBaseProduct = (product) => {
|
|
1679
1702
|
const { attributes, description, name } = product;
|