/** * {@inheritdoc} */ public function isEligible(PromotionSubjectInterface $promotionSubject, PromotionCouponInterface $promotionCoupon) { if (!$promotionSubject instanceof OrderInterface) { return true; } if (!$promotionCoupon instanceof CorePromotionCouponInterface) { return true; } $perCustomerUsageLimit = $promotionCoupon->getPerCustomerUsageLimit(); if ($perCustomerUsageLimit === null) { return true; } $customer = $promotionSubject->getCustomer(); if ($customer === null) { return true; } $placedOrdersNumber = $this->orderRepository->countByCustomerAndCoupon($customer, $promotionCoupon); return $placedOrdersNumber < $perCustomerUsageLimit; }