/** * Check for the rules required by the coupon * * @param CartCouponOnCheckEvent $event Event * * @throws CouponRulesNotValidateException */ public function checkCoupon(CartCouponOnCheckEvent $event) { $isValid = $this->cartCouponRuleManager->checkCouponValidity($event->getCart(), $event->getCoupon()); if (!$isValid) { throw new CouponRulesNotValidateException(); } }
/** * Check if cart meets basic requirements for a coupon * * @param CartCouponOnCheckEvent $event * * @throws AbstractCouponException */ public function checkCoupon(CartCouponOnCheckEvent $event) { if ($event->getCart()->getTotalItemNumber() === 0) { throw new CouponIncompatibleException(); } $coupon = $event->getCoupon(); $this->couponManager->checkCoupon($coupon); }
/** * Check if cart meets minimum price requirements for a coupon * * @param CartCouponOnCheckEvent $event Event * * @return null * * @throws CouponBelowMinimumPurchaseException Minimum value not reached */ public function checkMinimumPrice(CartCouponOnCheckEvent $event) { $couponMinimumPrice = $event->getCoupon()->getMinimumPurchase(); if ($couponMinimumPrice->getAmount() === 0) { return null; } $productMoney = $event->getCart()->getProductAmount(); if ($couponMinimumPrice->getCurrency() != $productMoney->getCurrency()) { $couponMinimumPrice = $this->currencyConverter->convertMoney($couponMinimumPrice, $productMoney->getCurrency()); } if ($productMoney->isLessThan($couponMinimumPrice)) { throw new CouponBelowMinimumPurchaseException(); } }
/** * Check if cart meets basic requirements for a coupon. * * @param CartCouponOnCheckEvent $event * * @throws AbstractCouponException */ public function validateCoupon(CartCouponOnCheckEvent $event) { $this->cartCouponValidator->validateCoupon($event->getCart(), $event->getCoupon()); }
/** * Check if cart meets minimum price requirements for a coupon * * @param CartCouponOnCheckEvent $event Event */ public function validateCartCouponMinimumPrice(CartCouponOnCheckEvent $event) { $this->cartCouponMinimumPriceValidator->validateCartCouponMinimumPrice($event->getCart(), $event->getCoupon()); }