public function validateCartCouponRules(
        CartInterface $cart,
        CouponInterface $coupon
    ) {
        $rule = $coupon->getRule();

        if (null === $rule) {
            return;
        }

        try {
            $isValid = $this
                ->ruleManager
                ->evaluate(
                    $rule,
                    [
                        'cart' => $cart,
                        'coupon' => $coupon,
                    ]
                );

            if (!$isValid) {
                throw new CouponRulesNotValidateException();
            }

            return;
        } catch (Exception $e) {
            // Maybe log something in case of exception?
        }

        throw new CouponRulesNotValidateException();
    }
public function validateCartCouponRules(
        CartInterface $cart,
        CouponInterface $coupon
    ) {
        $rule = $coupon->getRule();

        if (null === $rule) {
            return;
        }

        try {
            $isValid = $this
                ->ruleManager
                ->evaluate(
                    $rule,
                    [
                        'cart' => $cart,
                        'coupon' => $coupon,
                    ]
                );

            if (!$isValid) {
                throw new CouponRulesNotValidateException();
            }

            return;
        } catch (Exception $e) {
            // Maybe log something in case of exception?
        }

        throw new CouponRulesNotValidateException();
    }
public function validateCartCouponRules ( CartInterface $ cart , CouponInterface $ coupon ) { $ rule = $ coupon -> getRule ( ) ; if ( null === $ rule ) { return ; } try { $ isValid = $ this -> ruleManager -> evaluate ( $ rule , [ 'cart' => $ cart , 'coupon' => $ coupon , ] ) ; if ( ! $ isValid ) { throw new CouponRulesNotValidateException ( ) ; } return ; } catch ( Exception $ e ) { // Maybe log something in case of exception? } throw new CouponRulesNotValidateException ( ) ; }
Checks if given Coupon is valid. To determine its validity, this service
will evaluate all rules if there are any.

@param CartInterface   $cart   Cart
@param CouponInterface $coupon Coupon

@throws CouponRulesNotValidateException Rules not valid
Checks if given Coupon is valid . To determine its validity this service will evaluate all rules if there are any .