templates/cart/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Mon panier - La Boutique Belge{% endblock %}
  3. {% block content %}
  4.     <h1>Mon panier</h1>
  5.     <p class="mt-3 mb-5">Retrouvez l'ensemble des produits que vous avez ajoutés à votre panier.</p>
  6.     {% if cart|length > 0 %}
  7.         <table class="table mt-3">
  8.             <thead>
  9.                 <tr>
  10.                     <th scope="col"></th>
  11.                     <th scope="col">Produit</th>
  12.                     <th scope="col">Quantité</th>
  13.                     <th scope="col">Prix</th>
  14.                     <th scope="col">Total</th>
  15.                     <th scope="col"></th>
  16.                 </tr>
  17.             </thead>
  18.             <tbody>
  19.                 {% set total = 0 %}
  20.                 {% for product in cart %}                  
  21.                     <tr>
  22.                         <td>
  23.                             <img src="/uploads/{{ product.product.illustration }}" height="75" alt="{{ product.product.name }}">
  24.                         </td>
  25.                         <td>{{ product.product.name }}</td>
  26.                         <td>
  27.                             {% if app.user and product.product.productId is not empty %}
  28.                                 <a href="{{ path('decrease_to_cart', { 'id': product.product.productId }) }}">
  29.                                     <img src="{{ asset('assets/img/minus.png') }}" height="12" alt="Ajouter un produit">
  30.                                 </a>
  31.                             {% elseif not app.user %}
  32.                                 <a href="{{ path('decrease_to_cart', { 'id': product.product.id }) }}">
  33.                                     <img src="{{ asset('assets/img/minus.png') }}" height="12" alt="Ajouter un produit">
  34.                                 </a>
  35.                             {% endif %}
  36.                             {{ product.quantity }}                            
  37.                             {% if app.user and product.product.productId is not empty %}
  38.                                 <a href="{{ path('add_to_cart', { 'id': product.product.productId }) }}">
  39.                                     <img src="{{ asset('assets/img/plus.png') }}" height="12" alt="Retirer une quantité au produit">
  40.                                 </a>
  41.                             {% elseif not app.user %}
  42.                                 <a href="{{ path('add_to_cart', { 'id': product.product.id }) }}">
  43.                                     <img src="{{ asset('assets/img/plus.png') }}" height="12" alt="Retirer une quantité au produit">
  44.                                 </a>
  45.                             {% endif %}
  46.                         </td>
  47.                         <td>{{ (product.product.price / 100) | number_format(2, ',', '.') }} €</td>
  48.                         <td>{{ ((product.product.price * product.quantity) / 100) | number_format(2, ',', '.') }} €</td>
  49.                         <td>
  50.                             {% if app.user and product.product.productId is not empty %}
  51.                                 <a href="{{ path('add_to_cart', { 'id': product.product.productId }) }}">
  52.                                     <img src="{{ asset('assets/img/plus.png') }}" height="12" alt="Retirer une quantité au produit">
  53.                                 </a>
  54.                                  <a href="{{ path('delete_to_cart', { 'id': product.product.productId }) }}">
  55.                                     <img src="{{ asset('assets/img/delete.png') }}" height="12" alt="Supprimer mon produit">
  56.                                 </a>
  57.                             {% elseif not app.user %}
  58.                                 <a href="{{ path('delete_to_cart', { 'id': product.product.id }) }}">
  59.                                     <img src="{{ asset('assets/img/delete.png') }}" height="12" alt="Supprimer mon produit">
  60.                                 </a>
  61.                             {% endif %}
  62.                         </td>
  63.                     </tr>
  64.                     {% set total = total + (product.product.price * product.quantity) %}
  65.                 {% endfor %}
  66.             </tbody>
  67.         </table>
  68.         <div class="text-right mb-5">
  69.             <b>Nombre de produits :</b> {{ cart|length }}
  70.             <br>
  71.             <b>Total de mon panier :</b> {{ (total / 100) | number_format(2, ',', '.') }} €
  72.             <br>
  73.             <a href="{{ path('order') }}" class="btn btn-success btn-block">Valider mon panier</a>
  74.         </div>
  75.     {% else %}
  76.         <hr>
  77.         <p><b>Votre panier est vide</b></p>
  78.     {% endif %}
  79. {% endblock %}