diff --git a/includes/api/coupon-apply.php b/includes/api/coupon-apply.php index d96ed85a..1ea29dae 100644 --- a/includes/api/coupon-apply.php +++ b/includes/api/coupon-apply.php @@ -59,6 +59,21 @@ function applyCouponOnCart(WP_REST_Request $request) return new WP_REST_Response($response, 400); } + //check woo-discount-rule plugin disabling the coupons + $discountOptions = get_option('woo-discount-config-v2', []); + if (!empty($discountOptions)) { + $isCouponEnabled = $discountOptions['disable_coupon_when_rule_applied']; + if ($isCouponEnabled == 'disable_coupon') { + $response["failure_reason"] = "Coupon feature disabled"; + $response["failure_code"] = "INVALID_COUPON"; + $logObj["response"] = $response; + + rzpLogError(json_encode($logObj)); + + return new WP_REST_Response($response, 400); + } + } + if (empty($coupon->get_email_restrictions()) === false) { if ($email == "") { $response["failure_reason"] = "User email is required"; diff --git a/includes/api/coupon-get.php b/includes/api/coupon-get.php index cbcd8d27..4c240d06 100755 --- a/includes/api/coupon-get.php +++ b/includes/api/coupon-get.php @@ -67,6 +67,15 @@ function getCouponList($request) 'posts_per_page' => -1, // By default WP_Query will return only 10 posts, to avoid that we need to pass -1 ); + //check woo-discount-rule plugin disabling the coupons + $discountOptions = get_option('woo-discount-config-v2', []); + if (!empty($discountOptions)) { + $isCouponEnabled = $discountOptions['disable_coupon_when_rule_applied']; + if ($isCouponEnabled == 'disable_coupon') { + $args = array(); + } + } + $coupons = new WP_Query($args); $couponData['promotions'] = array();