Skip to content
Snippets Groups Projects
Commit 75009211 authored by Axel Po's avatar Axel Po
Browse files

fix: filter cart by user_id

parent e4d9515d
2 merge requests!6Dev,!4Feat/cart
......@@ -18,8 +18,11 @@ class CartController extends AbstractController
#[Route('/', name: 'app_cart_index', methods: ['GET'])]
public function index(CartRepository $cartRepository): Response
{
$user = $this->getUser(); // Get the current user object
$carts = $cartRepository->findBy(['user_id' => $user]); // Get the carts for the current user
return $this->render('cart/index.html.twig', [
'carts' => $cartRepository->findAll(),
'carts' => $carts,
]);
}
......
......@@ -72,7 +72,7 @@
<a
class="bg-[#F5B100] py-2 px-6 rounded-md"
href="{{ path('app_cart_index') }}"
>Voir mon pannier</a
>Voir mon panier</a
>
{% endif %} {% endif %}
......
......@@ -19,7 +19,7 @@ body %}
</div>
</div>
<div>
<span class="font-bold text-orange-500 text-lg">4</span>
<span class="font-bold text-orange-500 text-lg">{{ cart.getProductId().first().getPrice() }}</span>
</div>
</div>
<div class="flex gap-6 mt-6">
......@@ -28,13 +28,15 @@ body %}
</div>
</article>
{% else %}
<p>Votre pannier est vide !</p>
<p>Votre panier est vide !</p>
{% endfor %}
</div>
<a href="#">Retour aux achats</a>
</section>
{% endblock %} {# {% extends 'base.html.twig' %} {% block title %}Cart index{%
{% endblock %}
{# {% extends 'base.html.twig' %} {% block title %}Cart index{%
endblock %} {% block body %}
<h1>Cart index</h1>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment