瀏覽代碼

Modifications OrderUtils

master
Guillaume 4 年之前
父節點
當前提交
da31cfdd02
共有 1 個文件被更改,包括 20 次插入13 次删除
  1. +20
    -13
      ShopBundle/Services/OrderUtils.php

+ 20
- 13
ShopBundle/Services/OrderUtils.php 查看文件

@@ -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…
取消
儲存