浏览代码

Modification valeur de retour de OrderShopBuilder::addOrderProduct(): array

develop
Guillaume 2 年前
父节点
当前提交
6bda8950b9
共有 2 个文件被更改,包括 13 次插入12 次删除
  1. +8
    -9
      Builder/Order/OrderShopBuilder.php
  2. +5
    -3
      Controller/Order/CartController.php

+ 8
- 9
Builder/Order/OrderShopBuilder.php 查看文件

@@ -229,18 +229,18 @@ class OrderShopBuilder
OrderShopInterface $orderShop,
OrderProductInterface $orderProductAdd,
bool $persist = true
): bool {
$return = false;
): ?array {
$orderProductAddedArray = [];

$orderProductAdd->setOrderShop($orderShop);

if ($this->orderShopSolver->isOrderProductAvailableAddCart($orderProductAdd, $orderShop)) {
if ($orderProductAdd->getQuantityOrder() > 0) {
$orderProductAddedArray[] = $orderProductAdd;
$updated = false;

$this->orderProductBuilder->init($orderProductAdd);

//TODO vérifier ma modif ici
if(is_null($orderProductAdd->getOrderProductReductionCatalog())) {
// on hydrate $productFamily avec réduction
$productFamily = $this->productFamilyStore->setSection($orderShop->getSection())->getOneBySlug(
@@ -250,6 +250,7 @@ class OrderShopBuilder
$this->orderProductBuilder->initReductionCatalog($orderShop->getSection(), $orderProductAdd, $productFamily);
}
}

foreach ($orderShop->getOrderProducts() as $orderProduct) {
if ($this->orderProductSolver->compare($orderProduct, $orderProductAdd)) {

@@ -262,8 +263,6 @@ class OrderShopBuilder
}

$updated = true;
$return = true;

break;
}
}
@@ -279,8 +278,6 @@ class OrderShopBuilder
$this->entityManager->persist($orderProductAdd);
$this->entityManager->update($orderShop);
}

$return = true;
}

if ($persist) {
@@ -310,11 +307,13 @@ class OrderShopBuilder
}
}
$this->utils->addFlash('error', $textError);*/
}

$return = false;
if(count($orderProductAddedArray) == 0) {
return null;
}

return $return;
return $orderProductAddedArray;
}

public function merge(

+ 5
- 3
Controller/Order/CartController.php 查看文件

@@ -78,13 +78,15 @@ class CartController extends AbstractController
public function addOrderProduct(OrderShopInterface $orderShop, OrderProductInterface $orderProduct): void
{
$this->quantityOrder = $orderProduct->getQuantityOrder();
$addOrderProduct = $this->getOrderShopContainer()->getBuilder()->addOrderProduct(
$orderProductArray = $this->getOrderShopContainer()->getBuilder()->addOrderProduct(
$orderShop,
$orderProduct
);

if (isset($addOrderProduct) && $addOrderProduct && $orderProduct->getQuantityOrder() > 0) {
$this->orderProducts[] = $orderProduct;
if (is_array($orderProductArray)) {
foreach($orderProductArray as $orderProduct) {
$this->orderProducts[] = $orderProduct;
}
}
}


正在加载...
取消
保存