templates/partials/_product_card.html.twig line 1

Open in your IDE?
  1. {% set label_raw = label_raw ?? false %}
  2. {% set show_description = show_description ?? false %}
  3. {% set price_prefix = price_prefix ?? 'FCFA' %}
  4. {% set price_separator = price_separator is defined ? price_separator : ' ' %}
  5. {% set price_format = price_format ?? true %}
  6. {% set product_images = Produit.images|default([]) %}
  7. {% set main_image = product_images|first %}
  8. {% set main_image_url = main_image ? main_image.url : ('uploads/brochures/' ~ Produit.getIMAGE()) %}
  9. {% set main_image_src = main_image_url matches '/^https?:\\/\\//i' ? main_image_url : asset(main_image_url) %}
  10. {% set gallery_id = 'productGallery' ~ Produit.getid() %}
  11. {% set carousel_id = gallery_id ~ 'Carousel' %}
  12. <div class="featured__item product-card">
  13.     <div class="product-card__media">
  14.         <button type="button" class="product-card__image-button" data-toggle="modal" data-target="#{{ gallery_id }}" aria-label="Voir les images de {{ Produit.getLIBELLE()|striptags }}">
  15.             <img class="product-card__img" src="{{ main_image_src }}" alt="{{ Produit.getLIBELLE()|striptags }}">
  16.             {% if product_images|length > 1 %}
  17.                 <span class="product-card__image-count">{{ product_images|length > 4 ? 4 : product_images|length }} images</span>
  18.             {% endif %}
  19.         </button>
  20.         <div class="product-card__overlay">
  21.             <a class="product-card__icon" href="{{ path('trcoeur_add', {'id': Produit.getid()}) }}" aria-label="Ajouter aux favoris">
  22.                 <i class="fa fa-heart"></i>
  23.             </a>
  24.             <a class="product-card__icon" href="{{ path('TrPanier_Addition', {'id': Produit.getid()}) }}" aria-label="Ajouter au panier">
  25.                 <i class="fa fa-shopping-cart"></i>
  26.             </a>
  27.         </div>
  28.     </div>
  29.     <div class="featured__item__text product-card__content">
  30.         <h6 class="product-card__title">
  31.             <a href="#">
  32.                 {% if label_raw %}
  33.                     {{ Produit.getLIBELLE()|raw }}
  34.                 {% else %}
  35.                     {{ Produit.getLIBELLE()|e }}
  36.                 {% endif %}
  37.             </a>
  38.         </h6>
  39.         {% if show_description %}
  40.             <p class="product-card__subtitle">{{ Produit.getDescription()|raw }}</p>
  41.         {% endif %}
  42.         <div class="product-card__price{% if Produit.hasPromotion() %} product-card__price--promo{% endif %}">
  43.             {% if Produit.hasPromotion() %}
  44.                 <div class="product-card__promo-top">
  45.                     <span class="product-card__badge">Promo</span>
  46.                     {% if Produit.pourcentageReduction is not null %}
  47.                         <span class="product-card__discount">-{{ Produit.pourcentageReduction }}%</span>
  48.                     {% endif %}
  49.                 </div>
  50.                 <span class="product-card__price-current">
  51.                     {{ price_prefix }}{{ price_separator }}{% if price_format %}{{ Produit.getPrixActuel()|number_format(0, ',', ' ') }}{% else %}{{ Produit.getPrixActuel() }}{% endif %}
  52.                 </span>
  53.                 <span class="product-card__price-old">
  54.                     {{ price_prefix }}{{ price_separator }}{% if price_format %}{{ Produit.getPRIX()|number_format(0, ',', ' ') }}{% else %}{{ Produit.getPRIX() }}{% endif %}
  55.                 </span>
  56.             {% else %}
  57.                 <span class="product-card__price-current">
  58.                     {{ price_prefix }}{{ price_separator }}{% if price_format %}{{ Produit.getPrixActuel()|number_format(0, ',', ' ') }}{% else %}{{ Produit.getPrixActuel() }}{% endif %}
  59.                 </span>
  60.             {% endif %}
  61.         </div>
  62.     </div>
  63. </div>
  64. <div class="modal fade product-gallery-modal" id="{{ gallery_id }}" tabindex="-1" role="dialog" aria-hidden="true">
  65.     <div class="modal-dialog modal-dialog-centered modal-lg" role="document">
  66.         <div class="modal-content">
  67.             <div class="modal-header">
  68.                 <h5 class="modal-title">{{ Produit.getLIBELLE()|striptags }}</h5>
  69.                 <button type="button" class="close" data-dismiss="modal" aria-label="Fermer">
  70.                     <span aria-hidden="true">&times;</span>
  71.                 </button>
  72.             </div>
  73.             <div class="modal-body">
  74.                 <div id="{{ carousel_id }}" class="carousel slide product-gallery" data-ride="false" data-interval="false">
  75.                     <div class="carousel-inner">
  76.                         {% for image in product_images|slice(0, 4) %}
  77.                             {% set image_url = image.url %}
  78.                             {% set image_src = image_url matches '/^https?:\\/\\//i' ? image_url : asset(image_url) %}
  79.                             <div class="carousel-item {% if loop.first %}active{% endif %}">
  80.                                 <img src="{{ image_src }}" class="product-gallery__image" alt="{{ Produit.getLIBELLE()|striptags }} image {{ loop.index }}">
  81.                                 <div class="product-gallery__counter">{{ loop.index }}/{{ product_images|length > 4 ? 4 : product_images|length }}</div>
  82.                             </div>
  83.                         {% endfor %}
  84.                     </div>
  85.                     {% if product_images|length > 1 %}
  86.                         <a class="carousel-control-prev" href="#{{ carousel_id }}" role="button" data-slide="prev" aria-label="Image precedente">
  87.                             <span class="carousel-control-prev-icon" aria-hidden="true"></span>
  88.                         </a>
  89.                         <a class="carousel-control-next" href="#{{ carousel_id }}" role="button" data-slide="next" aria-label="Image suivante">
  90.                             <span class="carousel-control-next-icon" aria-hidden="true"></span>
  91.                         </a>
  92.                     {% endif %}
  93.                 </div>
  94.                 <div class="product-gallery__details">
  95.                     {% if show_description and Produit.getDescription() %}
  96.                         <p>{{ Produit.getDescription()|raw }}</p>
  97.                     {% endif %}
  98.                     <div class="product-gallery__price">
  99.                         {% if Produit.hasPromotion() %}
  100.                             <span>{{ price_prefix }}{{ price_separator }}{% if price_format %}{{ Produit.getPrixActuel()|number_format(0, ',', ' ') }}{% else %}{{ Produit.getPrixActuel() }}{% endif %}</span>
  101.                             <del>{{ price_prefix }}{{ price_separator }}{% if price_format %}{{ Produit.getPRIX()|number_format(0, ',', ' ') }}{% else %}{{ Produit.getPRIX() }}{% endif %}</del>
  102.                         {% else %}
  103.                             <span>{{ price_prefix }}{{ price_separator }}{% if price_format %}{{ Produit.getPrixActuel()|number_format(0, ',', ' ') }}{% else %}{{ Produit.getPrixActuel() }}{% endif %}</span>
  104.                         {% endif %}
  105.                     </div>
  106.                 </div>
  107.             </div>
  108.             <div class="modal-footer">
  109.                 <button type="button" class="btn btn-light" data-dismiss="modal">Fermer</button>
  110.                 <a class="btn btn-success" href="{{ path('TrPanier_Addition', {'id': Produit.getid()}) }}">Ajouter au panier</a>
  111.             </div>
  112.         </div>
  113.     </div>
  114. </div>