@cloudcommerce/app-discounts 2.29.20 → 2.30.1

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.
@@ -121,6 +121,14 @@ const getValidDiscountRules = (discountRules, params, itemsForKit) => {
121
121
  value += price * item.quantity;
122
122
  }
123
123
  });
124
+ if (rule.min_quantity > 1) {
125
+ const totalQuantity = itemsForKit.reduce((acc, item) => {
126
+ return item.quantity + acc;
127
+ }, 0);
128
+ if (totalQuantity > rule.min_quantity) {
129
+ value *= (rule.min_quantity / totalQuantity);
130
+ }
131
+ }
124
132
  }
125
133
  if (value) {
126
134
  if (rule.discount && rule.discount.value) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-discounts",
3
3
  "type": "module",
4
- "version": "2.29.20",
4
+ "version": "2.30.1",
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.29.20"
26
+ "@cloudcommerce/api": "2.30.1"
27
27
  },
28
28
  "devDependencies": {
29
- "@cloudcommerce/types": "2.29.20"
29
+ "@cloudcommerce/types": "2.30.1"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "bash ../../../scripts/build-lib.sh"