@cloudcommerce/app-discounts 2.40.0 → 2.40.2
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/lib-mjs/helpers.mjs +6 -4
- package/package.json +3 -3
package/lib-mjs/helpers.mjs
CHANGED
|
@@ -115,16 +115,15 @@ const getValidDiscountRules = (discountRules, params, itemsForKit) => {
|
|
|
115
115
|
});
|
|
116
116
|
} else if (rule.discount_kit_subtotal) {
|
|
117
117
|
value = 0;
|
|
118
|
+
let totalQuantity = 0;
|
|
118
119
|
itemsForKit.forEach((item) => {
|
|
119
120
|
const price = ecomUtils.price(item);
|
|
120
121
|
if (price > 0 && checkProductId(item)) {
|
|
121
122
|
value += price * item.quantity;
|
|
123
|
+
totalQuantity += item.quantity;
|
|
122
124
|
}
|
|
123
125
|
});
|
|
124
126
|
if (rule.min_quantity > 1) {
|
|
125
|
-
const totalQuantity = itemsForKit.reduce((acc, item) => {
|
|
126
|
-
return item.quantity + acc;
|
|
127
|
-
}, 0);
|
|
128
127
|
if (totalQuantity > rule.min_quantity) {
|
|
129
128
|
value *= (rule.min_quantity / totalQuantity);
|
|
130
129
|
}
|
|
@@ -215,7 +214,10 @@ const matchDiscountRule = (_discountRules, params = {}, skipApplyAt) => {
|
|
|
215
214
|
// then try to match by domain
|
|
216
215
|
if (params.domain) {
|
|
217
216
|
const discountRule = filteredRules.find((rule) => {
|
|
218
|
-
|
|
217
|
+
if (rule.domain === params.domain || params.domain === `${rule.domain}.skip-open`) {
|
|
218
|
+
return !rule.discount_coupon && !rule.utm_campaign && !rule.customer_ids?.length;
|
|
219
|
+
}
|
|
220
|
+
return false;
|
|
219
221
|
});
|
|
220
222
|
if (discountRule) {
|
|
221
223
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-discounts",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.40.
|
|
4
|
+
"version": "2.40.2",
|
|
5
5
|
"description": "e-com.plus Cloud Commerce app for complex discount rules",
|
|
6
6
|
"main": "lib/discounts.js",
|
|
7
7
|
"files": [
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"homepage": "https://github.com/ecomplus/cloud-commerce/tree/main/packages/apps/discounts#readme",
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ecomplus/utils": "1.5.0-rc.6",
|
|
26
|
-
"@cloudcommerce/api": "2.40.
|
|
26
|
+
"@cloudcommerce/api": "2.40.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@cloudcommerce/types": "2.40.
|
|
29
|
+
"@cloudcommerce/types": "2.40.2"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "bash ../../../scripts/build-lib.sh"
|