|
|
@@ -21,7 +21,6 @@ class CartController extends AbstractController |
|
|
|
protected int $quantityOrder = 1; |
|
|
|
protected array $orderProducts = []; |
|
|
|
|
|
|
|
//TODO Refactorer cette méthode ligne 48 return false !!! Pas possible, de plus elle retourne un json vide ... |
|
|
|
public function addProductFamily(Request $request): JsonResponse |
|
|
|
{ |
|
|
|
$user = $this->getUserCurrent(); |
|
|
@@ -34,6 +33,10 @@ class CartController extends AbstractController |
|
|
|
$idProductFamily = $data['order_products']['id_product_family']; |
|
|
|
$this->productFamily = $this->getProductFamilyContainer()->getStore()->getOneById($idProductFamily); |
|
|
|
|
|
|
|
if(!$this->productFamily) { |
|
|
|
$return['return'] = 'error'; |
|
|
|
} |
|
|
|
|
|
|
|
// alerte si cookies non acceptés |
|
|
|
if (!$user && !$visitor) { |
|
|
|
$this->addFlash( |
|
|
@@ -45,7 +48,7 @@ class CartController extends AbstractController |
|
|
|
'fos_user_security_login' |
|
|
|
) . '">connecter</a> pour ajouter un produit.' |
|
|
|
); |
|
|
|
return false; |
|
|
|
$return['return'] = 'error'; |
|
|
|
} |
|
|
|
|
|
|
|
if ($this->productFamily) { |
|
|
@@ -69,6 +72,8 @@ class CartController extends AbstractController |
|
|
|
$this->addOrderProduct($orderShop, $orderProduct); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$return['return'] = 'success'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |