@@ -290,7 +290,7 @@ class OrderController extends AdminController | |||
if ($formOrderReductionCart->isSubmitted() && $formOrderReductionCart->isValid()) { | |||
$reductionCart = $formOrderReductionCart->get('reductionCart')->getData(); | |||
$orderShop->reductionError = array(); | |||
if ($this->orderUtils->isReductionCartAllowToBeAddToOrder($orderShop, $reductionCart)) { | |||
if ($this->orderUtils->isReductionCartAllowAddToOrder($orderShop, $reductionCart)) { | |||
$orderReductionCart = $this->orderUtils->createOrderReductionCart($orderShop, $reductionCart); | |||
$this->em->persist($orderReductionCart); | |||
$this->em->flush(); |
@@ -40,7 +40,7 @@ abstract class AbstractEntity | |||
protected $updatedBy; | |||
public function addError($message, $domain = 'lcshop', $params){ | |||
public function addError($message, $domain = 'lcshop', $params = []){ | |||
$this->errors[] = array( | |||
'message'=> $message, | |||
'domain'=> $domain, |
@@ -43,7 +43,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt | |||
$query = $this->findByMerchantQuery(); | |||
$query = $this->filterOrderValid($query); | |||
$query->select('count(e.id)'); | |||
$query->join('e.orderReductionCart', 'orc'); | |||
$query->join('e.orderReductionCarts', 'orc'); | |||
$query->andWhere('orc.reductionCart = :reductionCart'); | |||
$query->setParameter('reductionCart', $reductionCart); | |||
return $query->getQuery()->getSingleScalarResult(); | |||
@@ -55,7 +55,7 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt | |||
$query = $this->filterOrderValid($query); | |||
$query->select('count(e.id)'); | |||
$query->andWhere('e.user = :user'); | |||
$query->join('e.orderReductionCart', 'orc'); | |||
$query->join('e.orderReductionCarts', 'orc'); | |||
$query->andWhere('orc.reductionCart = :reductionCart'); | |||
$query->setParameter('reductionCart', $reductionCart); | |||
$query->setParameter('user', $user); |
@@ -69,7 +69,9 @@ class ReductionCartRepository extends BaseRepository implements DefaultRepositor | |||
$reductionCartsArray = [] ; | |||
foreach($reductionCarts as $reductionCart) { | |||
if($this->orderUtils->isReductionCartMatchWithUser($reductionCart, $user) | |||
&& $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user)) { | |||
&& $this->orderUtils->isReductionCartMatchWithGroupUser($reductionCart, $user) | |||
&& $this->orderUtils->countReductionCartAvailableForUser($reductionCart, $user)) { | |||
$reductionCartsArray[] = $reductionCart ; | |||
} | |||
} |