Browse Source

Modifications OrderUtils

master
Guillaume 4 years ago
parent
commit
da31cfdd02
1 changed files with 20 additions and 13 deletions
  1. +20
    -13
      ShopBundle/Services/OrderUtils.php

+ 20
- 13
ShopBundle/Services/OrderUtils.php View File

@@ -62,10 +62,13 @@ class OrderUtils
}

if($orderShopUser || $orderShopVisitor) {
if($orderShopUser && $orderShopVisitor && $orderShopVisitor->getOrderProducts() && count($orderShopVisitor->getOrderProducts())) {
if($orderShopUser && $orderShopVisitor && $orderShopUser != $orderShopVisitor && $orderShopVisitor->getOrderProducts() && count($orderShopVisitor->getOrderProducts())) {
$orderShop = $this->mergeOrderShops($orderShopUser, $orderShopVisitor) ;
$this->session->getFlashBag()->add('success', "Votre panier visiteur vient d'être fusionné avec votre panier client.") ;
}
$orderShop = $this->mergeOrderShops($orderShopUser, $orderShopVisitor) ;
else {
$orderShop = ($orderShopUser) ? $orderShopUser : $orderShopVisitor ;
}
}

if(!$user && !$visitor)
@@ -127,7 +130,7 @@ class OrderUtils
return $orderShop;
}

public function addOrderProduct($orderShop, $orderProductAdd)
public function addOrderProduct($orderShop, $orderProductAdd, $persist = true)
{
if ($orderProductAdd->getQuantityOrder() > 0) {
$updated = false;
@@ -156,7 +159,11 @@ class OrderUtils
&& $this->compareOrderProductReductionCatalog($orderProduct->getOrderProductReductionCatalog(), $orderProductAdd->getOrderProductReductionCatalog())) {

$orderProduct->setQuantityOrder($orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder());
$this->em->persist($orderProduct);

if($persist) {
$this->em->persist($orderProduct);
}

$updated = true;

break ;
@@ -166,15 +173,18 @@ class OrderUtils
if (!$updated) {
$orderShop->addOrderProduct($orderProductAdd);

if(isset($orderProductReductionCatalog)) {
$this->em->persist($orderProductReductionCatalog);
if($persist) {
if(isset($orderProductReductionCatalog)) {
$this->em->persist($orderProductReductionCatalog);
}
$this->em->persist($orderProductAdd);
$this->em->persist($orderShop);
}

$this->em->persist($orderProductAdd);
$this->em->persist($orderShop);
}

$this->em->flush();
if($persist) {
$this->em->flush();
}
}

}
@@ -302,9 +312,6 @@ class OrderUtils

return $orderShop1 ;
}
else {
return ($orderShop1) ? $orderShop1 : $orderShop2 ;
}
}

}

Loading…
Cancel
Save