示例#1
0
 /**
  * Check if any of coupons applied in an order are from active referral
  * program line, being the customer, the invited.
  *
  * As invited, you can only have one ReferralLine enabled and not closed, so
  * this method search for this one
  *
  * @param CustomerInterface $customer Customer
  * @param Collection        $coupons  Coupons
  *
  * @return $this self Object
  */
 protected function checkCouponsUsedAsInvited(CustomerInterface $customer, Collection $coupons)
 {
     $referralLine = $this->referralLineRepository->findOneByInvited($customer);
     if (!$referralLine instanceof ReferralLineInterface) {
         return $this;
     }
     foreach ($coupons as $coupon) {
         /**
          * @var ReferralLineInterface $referralLine
          */
         if ($referralLine->getInvitedAssignedCoupon() == $coupon) {
             $referralLine->setInvitedCouponUsed(true);
             $this->manager->flush($referralLine);
         }
     }
     return $this;
 }