Skip to content

Commit c34f53c

Browse files
committed
fix(discounts): Handle new optional DISCOUNTS_DISABLE_OPEN bool env
1 parent 7ee98ca commit c34f53c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/apps/discounts/lib-mjs/helpers.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* eslint-disable default-param-last, no-use-before-define */
22
import ecomUtils from '@ecomplus/utils';
33

4+
const { DISCOUNTS_DISABLE_OPEN } = process.env;
5+
const isOpenPromotionEnabled = DISCOUNTS_DISABLE_OPEN?.toLowerCase() !== 'true';
6+
47
const validateDateRange = (rule) => {
58
// filter campaings by date
69
const timestamp = Date.now();
@@ -62,6 +65,7 @@ const matchFreebieRule = (rule, params = {}) => {
6265
};
6366

6467
const checkOpenPromotion = (rule) => {
68+
if (!isOpenPromotionEnabled) return false;
6569
return !rule.discount_coupon && !rule.utm_campaign
6670
&& (!Array.isArray(rule.customer_ids) || !rule.customer_ids.length);
6771
};

0 commit comments

Comments
 (0)