@@ -17,6 +17,10 @@ class CartController extends BaseController | |||
protected $orderUtils ; | |||
protected $productFamilyRepository ; | |||
protected $productFamily ; | |||
protected $orderProducts = [] ; | |||
public function __construct(EntityManagerInterface $em, MerchantUtilsInterface $merchantUtils, OrderUtilsInterface $orderUtils) | |||
{ | |||
parent::__construct($em, $merchantUtils); | |||
@@ -30,9 +34,9 @@ class CartController extends BaseController | |||
$data = $request->request->all() ; | |||
if(isset($data['order_products']['id_product_family'])) { | |||
$idProductFamily = $data['order_products']['id_product_family'] ; | |||
$productFamily = $this->productFamilyRepository->find($idProductFamily) ; | |||
if($productFamily) { | |||
$form = $this->createForm(OrderProductsType::class, ['id_product_family' => $productFamily->getId()]); | |||
$this->productFamily = $this->productFamilyRepository->find($idProductFamily) ; | |||
if($this->productFamily) { | |||
$form = $this->createForm(OrderProductsType::class, ['id_product_family' => $this->productFamily->getId()]); | |||
$form->handleRequest($request); | |||
if ($form->isSubmitted() && $form->isValid()) { | |||
@@ -41,13 +45,16 @@ class CartController extends BaseController | |||
foreach($data as $orderProduct) { | |||
if($orderProduct instanceof OrderProductInterface) { | |||
$this->orderUtils->addOrderProduct($orderShop, $orderProduct) ; | |||
if($orderProduct->getQuantity() > 0) { | |||
$this->orderProducts[] = $orderProduct ; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
return new JsonResponse($data) ; | |||
return new JsonResponse($return) ; | |||
} | |||
public function addProduct() |
@@ -47,7 +47,7 @@ abstract class OrderProduct implements PriceInterface | |||
{ | |||
$product = $this->getProduct() ; | |||
$productFamily = $product->getProductFamily() ; | |||
$titleProduct = $product->getTitle() ; | |||
$titleProduct = $product->getTitleInherited() ; | |||
$titleProductFamily = $productFamily->getTitle() ; | |||
if(strlen($titleProduct) > 0 && strlen($titleProductFamily) > 0) { | |||
@@ -64,6 +64,36 @@ abstract class OrderProduct implements PriceInterface | |||
return $title ; | |||
} | |||
public function getTitleSummaryAfterAddCart() | |||
{ | |||
$title = '' ; | |||
$product = $this->getProduct() ; | |||
$productFamily = $product->getProductFamily() ; | |||
$titleProduct = $product->getTitleInherited() ; | |||
$titleProductFamily = $productFamily->getTitle() ; | |||
// multiple | |||
if($productFamily->getActiveProducts() && $productFamily->getBehaviorAddToCart() == 'multiple') { | |||
$title .= $titleProduct ; | |||
if($productFamily->hasProductsWithVariousWeight()) { | |||
$title .= ' - '.$product->getQuantityLabelInherited() ; | |||
} | |||
} | |||
// simple | |||
if($productFamily->getBehaviorAddToCart() == 'simple') { | |||
if($productFamily->getActiveProducts()) { | |||
$title .= $titleProduct ; | |||
if($productFamily->hasProductsWithVariousWeight()) { | |||
$title .= ' - '.$product->getQuantityLabelInherited() ; | |||
} | |||
} | |||
} | |||
return $title ; | |||
} | |||
public function getOrderShop(): ?OrderShop | |||
{ | |||
return $this->orderShop; |
@@ -8,21 +8,21 @@ lc_api: | |||
controller: Lc\ShopBundle\Controller\ApiController::getEntity | |||
lc_frontend_cart_add_product_family: | |||
path: /cart/add-product-family | |||
path: /lc/cart/add/product-family | |||
controller: Lc\ShopBundle\Controller\Frontend\CartController::addProductFamily | |||
lc_frontend_cart_add_product: | |||
path: /cart/add-product | |||
path: /lc/cart/add/product | |||
controller: Lc\ShopBundle\Controller\Frontend\CartController::addProduct | |||
lc_frontend_cart_edit_product: | |||
path: /cart/edit-product | |||
path: /lc/cart/edit/product | |||
controller: Lc\ShopBundle\Controller\Frontend\CartController::editProduct | |||
lc_frontend_cart_delete_product: | |||
path: /cart/delete-product | |||
path: /lc/cart/delete/product | |||
controller: Lc\ShopBundle\Controller\Frontend\CartController::deleteProduct | |||
lc_frontend_cart_summary: | |||
path: /cart/summary | |||
path: /lc/cart/summary | |||
controller: Lc\ShopBundle\Controller\Frontend\CartController::summary |