if ($formOrderReductionCart->isSubmitted() && $formOrderReductionCart->isValid()) { | if ($formOrderReductionCart->isSubmitted() && $formOrderReductionCart->isValid()) { | ||||
$reductionCart = $formOrderReductionCart->get('reductionCart')->getData(); | $reductionCart = $formOrderReductionCart->get('reductionCart')->getData(); | ||||
$orderShop->reductionError = array(); | $orderShop->reductionError = array(); | ||||
if ($this->orderUtils->isReductionCartAllowToBeAddToOrder($orderShop, $reductionCart)) { | |||||
if ($this->orderUtils->isReductionCartAllowAddToOrder($orderShop, $reductionCart)) { | |||||
$orderReductionCart = $this->orderUtils->createOrderReductionCart($orderShop, $reductionCart); | $orderReductionCart = $this->orderUtils->createOrderReductionCart($orderShop, $reductionCart); | ||||
$this->em->persist($orderReductionCart); | $this->em->persist($orderReductionCart); | ||||
$this->em->flush(); | $this->em->flush(); |
protected $updatedBy; | protected $updatedBy; | ||||
public function addError($message, $domain = 'lcshop', $params){ | |||||
public function addError($message, $domain = 'lcshop', $params = []){ | |||||
$this->errors[] = array( | $this->errors[] = array( | ||||
'message'=> $message, | 'message'=> $message, | ||||
'domain'=> $domain, | 'domain'=> $domain, |
$query = $this->findByMerchantQuery(); | $query = $this->findByMerchantQuery(); | ||||
$query = $this->filterOrderValid($query); | $query = $this->filterOrderValid($query); | ||||
$query->select('count(e.id)'); | $query->select('count(e.id)'); | ||||
$query->join('e.orderReductionCart', 'orc'); | |||||
$query->join('e.orderReductionCarts', 'orc'); | |||||
$query->andWhere('orc.reductionCart = :reductionCart'); | $query->andWhere('orc.reductionCart = :reductionCart'); | ||||
$query->setParameter('reductionCart', $reductionCart); | $query->setParameter('reductionCart', $reductionCart); | ||||
return $query->getQuery()->getSingleScalarResult(); | return $query->getQuery()->getSingleScalarResult(); | ||||
$query = $this->filterOrderValid($query); | $query = $this->filterOrderValid($query); | ||||
$query->select('count(e.id)'); | $query->select('count(e.id)'); | ||||
$query->andWhere('e.user = :user'); | $query->andWhere('e.user = :user'); | ||||
$query->join('e.orderReductionCart', 'orc'); | |||||
$query->join('e.orderReductionCarts', 'orc'); | |||||
$query->andWhere('orc.reductionCart = :reductionCart'); | $query->andWhere('orc.reductionCart = :reductionCart'); | ||||
$query->setParameter('reductionCart', $reductionCart); | $query->setParameter('reductionCart', $reductionCart); | ||||
$query->setParameter('user', $user); | $query->setParameter('user', $user); |
$reductionCartsArray = [] ; | $reductionCartsArray = [] ; | ||||
foreach($reductionCarts as $reductionCart) { | foreach($reductionCarts as $reductionCart) { | ||||
if($this->orderUtils->isReductionCartMatchWithUser($reductionCart, $user) | if($this->orderUtils->isReductionCartMatchWithUser($reductionCart, $user) | ||||
&& $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user)) { | |||||
&& $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user) | |||||
&& $this->orderUtils->countReductionCartAvailableForUser($reductionCart, $user)) { | |||||
$reductionCartsArray[] = $reductionCart ; | $reductionCartsArray[] = $reductionCart ; | ||||
} | } | ||||
} | } |