isValid() public method

Checks whether the coupon is valid for use
public isValid ( WellCommerce\Bundle\CouponBundle\Entity\CouponInterface $coupon ) : boolean
$coupon WellCommerce\Bundle\CouponBundle\Entity\CouponInterface
return boolean
Example #1
0
 /**
  * @param CouponInterface|null $coupon
  *
  * @return bool
  * @throws CouponException
  */
 public function useCoupon(CouponInterface $coupon = null)
 {
     if (!$this->couponChecker->isValid($coupon)) {
         throw new CouponException($this->couponChecker->getError());
     }
     $this->applyCartCoupon($coupon);
     return true;
 }