Browse Source

Refactoring CartController

develop
Guillaume 2 years ago
parent
commit
def82abb63
1 changed files with 6 additions and 10 deletions
  1. +6
    -10
      Controller/Order/CartController.php

+ 6
- 10
Controller/Order/CartController.php View File

class CartController extends AbstractController class CartController extends AbstractController
{ {
protected ProductFamilyInterface $productFamily; protected ProductFamilyInterface $productFamily;
protected int $quantityOrder = 1;
protected array $orderProducts = []; protected array $orderProducts = [];


public function addProductFamily(Request $request): JsonResponse public function addProductFamily(Request $request): JsonResponse


public function addOrderProduct(OrderShopInterface $orderShop, OrderProductInterface $orderProduct): void public function addOrderProduct(OrderShopInterface $orderShop, OrderProductInterface $orderProduct): void
{ {
$this->addOrderProductApply($orderShop, $orderProduct);
}
$this->quantityOrder = $orderProduct->getQuantityOrder();
$addOrderProduct = $this->getOrderShopContainer()->getBuilder()->addOrderProduct(
$orderShop,
$orderProduct
);


public function addOrderProductApply(OrderShopInterface $orderShop, OrderProductInterface $orderProduct): void
{
if ($orderProduct->getQuantityOrder() > 0) {
$addOrderProduct = $this->getOrderShopContainer()->getBuilder()->addOrderProduct(
$orderShop,
$orderProduct
);
}
if (isset($addOrderProduct) && $addOrderProduct && $orderProduct->getQuantityOrder() > 0) { if (isset($addOrderProduct) && $addOrderProduct && $orderProduct->getQuantityOrder() > 0) {
$this->orderProducts[] = $orderProduct; $this->orderProducts[] = $orderProduct;
} }

Loading…
Cancel
Save