templates/main/product.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Les trésors de Luna{% endblock %}
  3. {% block javascripts %}
  4. <script type="module" src="{{asset('js/buying.js')}}"></script>
  5.   <script type="module" src="{{asset('js/classes/Cart.js')}}"></script>
  6. {% endblock javascripts %}
  7. {% block body %}
  8. <body>
  9.   <section id="banner" class="py-3" style="background: #F9F3EC;">
  10.     <div class="container">
  11.       <div class="hero-content py-5 my-3">
  12.         <h2 class="display-1 mt-3 mb-0">Détail du <span class="text-primary">Produit:</span></h2>
  13.         <nav class="breadcrumb">
  14.           <a class="breadcrumb-item nav-link" href="{{path('app_home')}}">Accueil</a>
  15.   
  16.           {% set search = path('search_products') %}
  17.           {% if search in comeFromPage %}
  18.             
  19.             <a class="breadcrumb-item nav-link" href="javascript:history.back()">Revenir aux résultats</a>
  20.             
  21.           {% endif %}
  22.           <span class="breadcrumb-item active" aria-current="page">{{product.name}}</span>
  23.         </nav>
  24.       </div>
  25.     </div>
  26.   </section>
  27.   <section id="selling-product">
  28.     <div class="container my-md-5 py-5">
  29.       <div class="row g-md-5">
  30.         <div class="col-lg-6">
  31.           <div class="row">
  32.             <div class="col-md-12">
  33.               <!-- product-large-slider -->
  34.               <div class="swiper product-large-slider">
  35.                 <div class="swiper-wrapper">
  36.                   <div class="swiper-slide">
  37.                     <img src="{{asset('uploads/product_images/' ~ product.mainImageLink)}}" class="img-fluid" />
  38.                   </div>
  39.                   <div class="swiper-slide">
  40.                     <img src="{{asset('uploads/product_images/' ~ product.Image0Link)}}" class="img-fluid" />
  41.                   </div>
  42.                   <div class="swiper-slide">
  43.                     <img src="{{asset('uploads/product_images/' ~ product.Image1Link)}}" class="img-fluid" />
  44.                   </div>
  45.                   <div class="swiper-slide">
  46.                     <img src="{{asset('uploads/product_images/' ~ product.Image2Link)}}" class="img-fluid" />
  47.                   </div>
  48.                 </div>
  49.               </div>
  50.             </div>
  51.             <div class="col-md-12 mt-2">
  52.               <!-- product-thumbnail-slider -->
  53.               <div thumbsSlider="" class="swiper product-thumbnail-slider">
  54.                 <div class="swiper-wrapper">
  55.                   <div class="swiper-slide" style="cursor: pointer;">
  56.                     <img src="{{asset('uploads/product_images/' ~ product.mainImageLink)}}" class="img-fluid" />
  57.                   </div>
  58.                   {% if product.image0Link %}  
  59.                     <div style="cursor: pointer;" class="swiper-slide">
  60.                       <img src="{{asset('uploads/product_images/' ~ product.image0Link)}}" class="img-fluid" />
  61.                     </div>
  62.                   {% endif %}
  63.                   {% if product.image1Link %}
  64.                     <div class="swiper-slide">
  65.                       <img src="{{asset('uploads/product_images/' ~ product.image1Link)}}" class="img-fluid" />
  66.                     </div>
  67.                   {% endif %}
  68.                 </div>
  69.               </div>
  70.             </div>
  71.           </div>
  72.         </div>
  73.         <div class="col-lg-6 mt-5 ">
  74.           <div class="product-info">
  75.             <div class="element-header">
  76.               <h2 id="product-name" itemprop="name" class="display-6">{{product.name}}</h2>
  77.             </div>
  78.             <div class="product-price pt-3 pb-3">
  79.               <strong id="product-price" data-price="{{product.price}}" class="text-primary display-6 fw-bold">{{product.price}}€</strong>
  80.             </div>
  81.             <p id="short-description">{{product.shortDescription|nl2br}}</p>
  82.             <div>
  83.               <span style="font-weight: bold; margin-right: 5px;">Categorie: </span>{{product.category.name}}
  84.             </div>
  85.             <div>
  86.               {% if product.stock >= 10 %}
  87.                 <span style="font-weight: bold; margin-right: 5px;">Stock disponible: </span> <span class="stock-indicator" style="font-weight: bold; font-size: 1.2rem; color: yellowgreen">{{product.stock}}</span><br>
  88.               {% endif %}
  89.               {% if product.stock < 10 and product.stock >= 5 %}
  90.                 <span style="font-weight: bold; margin-right: 5px">Stock disponible: </span> <span class="stock-indicator" style="font-weight: bold; font-size: 1.2rem; color: orange">{{product.stock}}</span><br>
  91.               {% endif %}
  92.               {% if product.stock < 5 %}
  93.                 <span style="font-weight: bold; margin-right: 5px">Stock disponible: </span> <span class="stock-indicator" style="font-weight: bold; font-size: 1.2rem; color: lightcoral">{{product.stock}}</span><br>
  94.               {% endif %}
  95.               <span style="font-weight: bold;">Poids: </span>{{product.weight}}g <br>
  96.               
  97.               {% if product.customizable %}
  98.               
  99.                 <label for="custom-message">Message personnalisé:</label>
  100.                 <input id="custom-message" name="custom-message" type="text" maxlength="200" placeholder="Votre message (200 caractères max.)" required> <br>
  101.                 <div id="error-message" style="color:red; font-size:0.9em; margin-bottom:0.5em;"></div>
  102.                 <label for="custom-police">Style du texte:</label>
  103.                 <input type="number" id="custom-police" name="custom-police" value="1" min="1" max="10" placeholder="Indiquez le numéro du style de texte" required> <br>
  104.                 <div id="error-police" style="color:red; font-size:0.9em; margin-bottom:0.5em;"></div>
  105.                 <label for="custom-image">Motifs : </label>
  106.                 <input type="number" id="custom-image" name="custom-image" value="1" min="1" max="5" placeholder="Indiquez le numéro du motif" required> <br>
  107.                 <input type="hidden" id="customizable-product" value="{{product.customizable}}">
  108.                 <div id="error-image" style="color:red; font-size:0.9em; margin-bottom:0.5em;"></div>
  109.                 
  110.               {% endif %}
  111.             </div>
  112.             
  113.             
  114.             <div class="cart-wrap">
  115.               <div class="product-quantity pt-2">
  116.                 <div class="stock-button-wrap">
  117.                   {% if product.stock != 0 %}
  118.                     <div style="display:flex; height: 30px;">
  119.                       <p style="width: 130px; margin:unset; padding: unset;">Quantité: </p>
  120.                       <div id="quantity-selector" class="input-group product-qty align-items-center w-25">
  121.                         <span class="input-group-btn">
  122.                           <button type="button" class="quantity-left-minus btn btn-light btn-number" data-type="minus">
  123.                             <svg width="16" height="16">
  124.                               <use xlink:href="#minus"></use>
  125.                             </svg>
  126.                           </button>
  127.                         </span>
  128.                         <input type="text" id="quantity" data-product-id="{{product.id}}" data-max-quantity="{{stock}}" name="quantity"
  129.                           class="form-control input-number text-center p-2 mx-1" value="1">
  130.                         <span class="input-group-btn">
  131.                           <button type="button" class="quantity-right-plus btn btn-light btn-number" data-type="plus"
  132.                             data-field="">
  133.                             <svg width="16" height="16">
  134.                               <use xlink:href="#plus"></use>
  135.                             </svg>
  136.                           </button>
  137.                         </span>
  138.                       </div>
  139.                     </div>
  140.                     <div class="d-flex flex-wrap pt-4" >
  141.                       <a href="{{path('add_to_cart', {'id': product.id})}}" data-max-quantity="{{stock}}" class="btn-cart btn-cart-buy me-3 px-4 pt-3 pb-3">
  142.                         <h5 class="text-uppercase m-0">Ajouter au panier</h5>
  143.                       </a>
  144.   
  145.                     </div>
  146.                   {% else %}  
  147.                     <p class="alert-stock">Produit indisponible</p>
  148.                   {% endif %}
  149.                 </div>
  150.               </div>
  151.             </div>
  152.             <div class="meta-product pt-4">
  153.             </div>
  154.           </div>
  155.         </div>
  156.       </div>
  157.     </div>
  158.   </section>
  159.   
  160.   {% if not product.additionalInformation and product.longDescription %}
  161.     
  162.     <section class="product-info-tabs py-md-5">
  163.       <div class="container">
  164.         <div class="row">
  165.           <div class="d-flex flex-column flex-md-row align-items-start gap-5">
  166.             <div class="nav flex-row flex-wrap flex-md-column nav-pills me-3 col-lg-3" id="v-pills-tab" role="tablist"
  167.               aria-orientation="vertical">
  168.                 {% if product.longDescription %}
  169.                   
  170.                 <button class="nav-link fs-5 mb-2 text-start active" id="v-pills-description-tab" data-bs-toggle="pill"
  171.                   data-bs-target="#v-pills-description" type="button" role="tab" aria-controls="v-pills-description"
  172.                   aria-selected="false" tabindex="-1">Description</button>
  173.                 {% endif %}
  174.                 {% if product.additionalInformation|nl2br %}
  175.                   <button class="nav-link fs-5 mb-2 text-start" id="v-pills-additional-tab" data-bs-toggle="pill"
  176.                     data-bs-target="#v-pills-additional" type="button" role="tab" aria-controls="v-pills-additional"
  177.                     aria-selected="false" tabindex="-1">Information additionnelle</button>
  178.                   
  179.                 {% endif %}
  180.                 {#
  181.               <button class="nav-link fs-5 mb-2 text-start" id="v-pills-reviews-tab" data-bs-toggle="pill"
  182.                 data-bs-target="#v-pills-reviews" type="button" role="tab" aria-controls="v-pills-reviews"
  183.                 aria-selected="true">Customer Reviews</button>
  184.                 #}
  185.             </div>
  186.             {% if product.longDescription %}
  187.               
  188.             <div class="tab-content" id="v-pills-tabContent">
  189.               <div class="tab-pane fade active show" id="v-pills-description" role="tabpanel"
  190.                 aria-labelledby="v-pills-description-tab" tabindex="0">
  191.                 <h2>Description du Produit</h2>
  192.                 <p>{{product.longDescription|nl2br}}</p>
  193.               </div>
  194.             {% endif %}
  195.               {% if product.additionalInformation %}
  196.               
  197.                 <div class="tab-pane fade" id="v-pills-additional" role="tabpanel" aria-labelledby="v-pills-additional-tab"
  198.                   tabindex="0">
  199.                   <h2>Information additionnelle</h2>
  200.                   <p>{{product.additionalInformation|nl2br}}</p>
  201.                 </div>
  202.                 
  203.               {% endif %}
  204.             </div>
  205.           </div>
  206.         </div>
  207.       </div>
  208.     </section>
  209.   {% endif %}
  210.   <div class="instagram-wrapper">
  211.     {{instagramLinks[0]["link0"]|raw}}
  212.     {{instagramLinks[1]["link1"]|raw}}
  213.     {{instagramLinks[2]["link2"]|raw}}
  214.     {{instagramLinks[3]["link3"]|raw}}
  215.     {{instagramLinks[4]["link4"]|raw}}
  216.   </div>
  217. <script>
  218.   document.addEventListener('DOMContentLoaded', function () {
  219.       const input = document.getElementById('custom-message');
  220.       const maxLength = parseInt(input.getAttribute('maxlength'), 10);
  221.       // Élément pour le compteur
  222.       const counter = document.createElement('div');
  223.       counter.style.fontSize = '0.9em';
  224.       counter.style.color = '#555';
  225.       counter.style.marginTop = '5px';
  226.       // Élément pour les erreurs
  227.       const feedback = document.createElement('div');
  228.       feedback.style.color = 'red';
  229.       feedback.style.marginTop = '2px';
  230.       input.insertAdjacentElement('afterend', counter);
  231.       counter.insertAdjacentElement('afterend', feedback);
  232.       updateDisplay();
  233.       input.addEventListener('input', updateDisplay);
  234.       function updateDisplay() {
  235.           const currentLength = input.value.length;
  236.           counter.textContent = `${currentLength} / ${maxLength} caractères`;
  237.           if (currentLength > maxLength) {
  238.               feedback.textContent = `⚠️ Le message dépasse la limite de ${maxLength} caractères.`;
  239.           } else {
  240.               feedback.textContent = '';
  241.           }
  242.       }
  243.   });
  244. </script>  
  245. </body>
  246. <script async src="//www.instagram.com/embed.js"></script>
  247. {% endblock body %}