templates/cart/index.html.twig line 1

  1. {% extends 'base.html.twig' %}
  2. {% block title %} Panier  {% endblock %}
  3. {% block body %}
  4.     <!-- ======================= Page Banner START -->
  5.     <section class="py-0">
  6.         <div class="container">
  7.             <div class="row">
  8.                 <div class="col-12">
  9.                     <div class="bg-light p-4 text-center rounded-3">
  10.                         <h1 class="m-0">Votre panier</h1>
  11.                         <!-- Breadcrumb -->
  12.                     </div>
  13.                 </div>
  14.             </div>
  15.         </div>
  16.     </section>
  17.     <!-- =======================
  18. Page content START -->
  19.     {% if cartProduct is not empty %}
  20.         <section class="pt-5">
  21.             <div class="container">
  22.                 <div class="row g-4 g-sm-5">
  23.                     {{ include ('components/flash_message.html.twig') }}
  24.                     <!-- Main content START -->
  25.                     <div class="col-lg-2 mb-4 mb-sm-0">
  26.                     </div>
  27.                     <div class="col-lg-8 mb-4 mb-sm-0">
  28.                         {% set total = 0 %}
  29.                         {% for  key, product in cartProduct %}
  30.                             {% if product.product is not empty %}
  31.                             {% set subtotal = product.product.price * product._shop_qnty %}
  32.                             {% set total = total + subtotal %}
  33.                             {% endif %}
  34.                             <div class="card border bg-white card-body cart-item" style="overflow: hidden;"
  35.                                  data-product-id="">
  36.                                 <p class="text-lg-center text-black">{{ product.product ? product.product.socialnetwork  : ''  }} {{ product.product ? product.product.category  : ''  }}
  37.                                     <a href="{{ path('remove_from_cart', {'productId': product.product_id}) }}"
  38.                                        class="blockOther text-black-50 remove-button"
  39.                                        style="float:right;cursor:pointer">
  40.                                         <i class="fas fa-times"></i> Supprimer
  41.                                     </a>
  42.                                     <span class="text-black" style="float:left;">
  43.                                         {{  product.product.socialnetwork  }}
  44.                                     </span></p>
  45.                                 <img class="avatar avatar-lg float-start me-3"
  46.                                      src="/service/{{ product.product.socialnetwork|lower }}.svg"
  47.                                      alt="{{ product.product.quality }}">
  48.                                 <hr>
  49.                                 <p class="text-black bi-shop"> {{ product._shop_src }}</p>
  50.                                 <hr>
  51.                                 <p class="text-black" style="text-align: left;">{{ product._shop_qnty }} рс.
  52.                                     x {{ product.product ? product.product.price : '' }} {{ product.product.currency}} =  {{ subtotal  ? subtotal : '' }} {{ product.product.currency}} ({{ product.product ? product.product.quality : '' }})</p>
  53.                             </div>
  54.                             <br>
  55.                         {% endfor %}
  56.                         <!-- Card total START -->
  57.                         <div class="card card-body p-4 shadow">
  58.                             <!-- Title -->
  59.                             <h4 class="mb-3"></h4>
  60.                             <!-- Button -->
  61.                             <div class="d-grid">
  62.                                 <a href="{{ path('app_checkout') }}" class="btn btn-lg btn-success">Passer à la
  63.                                     commande  {{ total ? total : '' }} € </a>
  64.                             </div>
  65.                         </div>
  66.                         <!-- Card total END -->
  67.                     </div>
  68.                     <!-- Main content END -->
  69.                 </div><!-- Row END -->
  70.             </div>
  71.         </section>
  72.         <!-- =======================
  73.         Page content END -->
  74.         <!-- ======================= Page Banner END -->
  75.     {% else %}
  76.         <section>
  77.             <div class="container">
  78.                 <div class="row">
  79.                     <div class="col-12 text-center">
  80.                         <!-- Image -->
  81.                         <img src="/assets/images/element/cart.svg" class="h-200px h-md-300px mb-3" alt="">
  82.                         <!-- Subtitle -->
  83.                         <h2>Votre panier est actuellement vide.</h2>
  84.                         <!-- info -->
  85.                         <p class="mb-0">Et si vous faisiez un tour dans notre catégorie ?</p>
  86.                         <!-- Button -->
  87.                         <a href="{{ path('app_defaut') }}" class="btn btn-primary mt-4 mb-0">Poursuivre mes achats</a>
  88.                     </div>
  89.                 </div>
  90.             </div>
  91.         </section>
  92.     {% endif %}
  93. {% endblock %}
  94. {% block head_js %}
  95.     {{ parent() }}
  96.     <script src="https://code.jquery.com/jquery-3.5.1.js"></script>
  97.     <script>
  98.         $(document).ready(function () {
  99.             // Handle remove button click
  100.             /* $('.remove-button').click(function() {
  101.                  // Get the parent cart item element and product ID
  102.                  var cartItem = $(this).closest('.cart-item');
  103.                  var productId = cartItem.data('product-id');
  104.                  // Remove the cart item element from the DOM
  105.                  cartItem.remove();
  106.                  // Send an AJAX request to remove the item from the server-side cart
  107.                  $.ajax({
  108.                      url: '/cart/remove/' + productId,
  109.                      method: 'POST',
  110.                      success: function(data) {
  111.                          console.log('Item removed from cart');
  112.                      },
  113.                      error: function() {
  114.                          console.log('Error removing item from cart');
  115.                      }
  116.                  });*/
  117.         });
  118.         })
  119.         ;
  120.     </script>
  121. {% endblock %}