src/Trinity/WebshopBundle/Resources/views/elements/productCard.html.twig line 1

Open in your IDE?
  1. {% trans_default_domain 'webshop' %}
  2. {% if config is defined %}
  3.     {% set allow_cart = config.allow_cart ?? false %}
  4.     {% set show_image = config.show_image ?? false %}
  5.     {% set allow_list = config.allow_list ?? false %}
  6.     {% set show_price = config.show_price ?? false %}
  7. {% else %}
  8.     {% set allow_cart = true %}
  9.     {% set show_image = true %}
  10.     {% set allow_list = true %}
  11.     {% set show_price = true %}
  12. {% endif %}
  13. {% if WebshopSettings is defined %}
  14.     {% if WebshopSettings.getB2b and WebshopSettings.hidePricesGuest %}
  15.         {% set show_price = false %}
  16.     {% endif %}
  17. {% endif %}
  18. {% if OriginalProduct is not defined %}
  19.     {% set OriginalProduct = Product %}
  20. {% endif %}
  21. {# {% if (OriginalProduct.type != 1 and OriginalProduct.type != 2) or OriginalProduct.linkedProducts.count > 0 %} #}
  22. {% if Settings.overridekey is defined and Settings.overridekey is not empty %}
  23.     {% set overridekey = Settings.overridekey %}
  24. {% endif %}
  25. {% if overridekey is defined and overridekey is not empty and file_exists('../templates/override/' ~ overridekey ~ '/webshop/productCard.html.twig') %}
  26.     {% include 'override/' ~ overridekey ~ '/webshop/productCard.html.twig' %}
  27. {% elseif file_exists('../templates/override/webshop/productCard.html.twig') %}
  28.     {% include 'override/webshop/productCard.html.twig' %}
  29. {% else %}
  30.     {% if catFix is defined and catFix %}
  31.         {% set Category = OriginalProduct.category.first %}
  32.     {% endif %}
  33.     {% if WebshopSettings.uriType == 1 %}
  34.         {% set productUrl = '' %}
  35.         {% set productUrl = productUrl ~ (WebshopSettings is defined and WebshopSettings.uri ? path('homepage') ~ WebshopSettings.uri : path('homepage')) %}
  36.         {% set productUrl = productUrl ~ ('Product' | trans({}) | lower | raw) %}
  37.         {% set productUrl = productUrl ~ '/' ~ Product.number %}
  38.         {% set productUrl = productUrl ~ '/' ~ Product.slug %}
  39.     {% else %}
  40.         {% if Settings.baseuri is empty %}
  41.             {% set site_baseuri = '' %}
  42.         {% else %}
  43.             {% set site_baseuri = Settings.baseuri | replace({'/': ''}) ~ '/' %}
  44.         {% endif %}
  45.         {% set productUrl = (WebshopSettings is defined and WebshopSettings.uri ? path('homepage') ~ WebshopSettings.uri : path('homepage') ~ site_baseuri ) ~ (Category.category is defined ? Category.category.uri : Category.uri) ~ '/' ~ (OriginalProduct is defined ? OriginalProduct.slug : Product.slug) %}
  46.     {% endif %}
  47. {% set childProductSale = false %}
  48. {% if OriginalProduct.linkedProducts.count > 0 %}
  49.     {% for CP in OriginalProduct.linkedProducts %}
  50.         {% if CP.hasPromotion or (CP.priceSale is not empty and CP.priceSale > 0) %}
  51.             {% set childProductSale = true %}
  52.         {% endif %}
  53.     {% endfor %}
  54. {% endif %}
  55.     <div class="card">
  56.             {% if list is defined %}
  57.                 <a href="{{path(app.request.attributes.get('_route'))}}?l={{list.id}}&d={{OriginalProduct.id}}" class="remove-from-list" title="{{'Verwijderen van lijst'|trans}}" data-id="{{OriginalProduct.id}}">
  58.                     <i class="fa fa-times"></i>
  59.                 </a>
  60.             {% endif %}
  61.             <a href="{{productUrl}}">
  62.                 {% if show_image %}
  63.                     <span class="badge-wrapper">
  64.                         {% if OriginalProduct.hasPromotion or (OriginalProduct.priceSale is not empty and OriginalProduct.priceSale > 0) or childProductSale %}
  65.                             <span class="sale-badge">{{'Sale'|trans}}</span>
  66.                         {% endif %}
  67.                         {% if OriginalProduct.exclusive is defined and OriginalProduct.exclusive %}
  68.                             <span class="exclusive-badge">{{'Exclusief'|trans({}, 'webshop', app.request.locale)}}</span>
  69.                         {% endif %}
  70.                         {% if OriginalProduct.hasCombi() %}
  71.                             <span class="combi-badge">{{'Combideal!'|trans({}, 'webshop', app.request.locale)}}</span>
  72.                         {% endif %}
  73.                         {% if OriginalProduct.new and OriginalProduct.newFrom <= date() and (OriginalProduct.newTill >= date() or OriginalProduct.newTill is empty) %}
  74.                             <span class="new-badge">{{'Nieuw'|trans}}</span>
  75.                         {% endif %}
  76.                     </span>
  77.                     <div class="card-image {{ OriginalProduct.media.count > 1 and WebshopSettings.imageSwap ? 'multi-image' : '' }}">
  78.                         <div class="img-first">
  79.                             <div class="lcp">
  80.                                 {% set media = OriginalProduct.media.first %}
  81.                                 {% if media %}
  82.                                     {% if media.hasBlurred %}
  83.                                         <picture>
  84.                                             {% if media.hasWebp() %}
  85.                                             <source srcset="/{{media.getBlurredWebpPath('small')}}" type="image/webp">
  86.                                             {% endif %}
  87.                                             <source srcset="/{{media.getBlurredWebPath('small')}}" type="{{media.mime}}">
  88.                                             <img class="lq" id="lq" alt="{{media.description_alt}}" src="/{{media.getBlurredWebPath('small')}}" type="{{media.mime}}" loading="lazy" height="{{media.height}}" style="opacity: 1;">
  89.                                         </picture>
  90.                                     {% endif %}
  91.                                     <picture>
  92.                                         {% if media.hasWebp() %}
  93.                                             <source srcset="/{{media.getWebpPath('medium')}}" type="image/webp">
  94.                                         {% endif %}
  95.                                         <source srcset="/{{media.getWebPath('medium')}}" type="{{media.mime}}">
  96.                                     <img class="hq" alt="{{media.description_alt}}" src="/{{media.getWebPath('medium')}}" type="{{media.mime}}" loading="lazy" height="{{media.height}}" onload="this.style.opacity=1; {% if media.hasBlurred %}this.closest('.lcp').getElementsByClassName('lq')[0].style.opacity=0;{% endif %}" style="opacity: 0;">
  97.                                     </picture>
  98.                                 {% else %}
  99.                                     <picture>
  100.                                         <img class="hq" src="{{(WebshopSettings.getDefaultProductImage is not empty ? WebshopSettings.getDefaultProductImage : '/bundles/trinitywebshop/img/no-product-image.png')}}" loading="lazy" onload="this.style.opacity=1" style="opacity: 0;">
  101.                                     </picture>
  102.                                 {% endif %}
  103.                             </div>
  104.                         </div>
  105.                         {% if OriginalProduct.media.count > 1 and WebshopSettings.imageSwap %}
  106.                             {% for i,media in OriginalProduct.media %}
  107.                                 {% if i == 1 %}
  108.                                 <div class="img-second">
  109.                                     <div class="lcp">
  110.                                         {% if media.hasBlurred %}
  111.                                             <picture>
  112.                                                 {% if media.hasWebp() %}
  113.                                                 <source srcset="/{{media.getBlurredWebpPath('small')}}" type="image/webp">
  114.                                                 {% endif %}
  115.                                                 <source srcset="/{{media.getBlurredWebPath('small')}}" type="{{media.mime}}">
  116.                                                 <img class="lq" id="lq" alt="{{media.description_alt}}" src="/{{media.getBlurredWebPath('small')}}" type="{{media.mime}}" loading="lazy" height="{{media.height}}" style="opacity: 1;">
  117.                                             </picture>
  118.                                         {% endif %}
  119.                                         <picture>
  120.                                             {% if media.hasWebp() %}
  121.                                                 <source srcset="/{{media.getWebpPath('medium')}}" type="image/webp">
  122.                                             {% endif %}
  123.                                             <source srcset="/{{media.getWebPath('medium')}}" type="{{ media.mime }}">
  124.                                             <img class="hq" alt="{{media.description_alt}}" src="/{{media.getWebPath('medium')}}" type="{{media.mime}}" loading="lazy" height="{{media.height}}" onload="this.style.opacity=1; {% if media.hasBlurred %}this.closest('.lcp').getElementsByClassName('lq')[0].style.opacity=0;{% endif %}" style="opacity: 0;">
  125.                                         </picture>
  126.                                     </div>
  127.                                 </div>
  128.                                 {% endif %}
  129.                             {% endfor %}
  130.                         {% endif %}
  131.                     </div>
  132.                 {% endif %}
  133.                 <div class="card-body">
  134.                     <div class="card-content">
  135.                         <h5 class="card-title">
  136.                             {{(OriginalProduct.brand ? OriginalProduct.brand.label ~ ' ' : '') ~ (OriginalProduct.label|raw)}}
  137.                         </h5>
  138.                         {% if hide_intro is not defined %}
  139.                             <div class="intro-wrapper">
  140.                                 {# <div class="intro">{{OriginalProduct.intro|striptags}}</div> #}
  141.                                 <div class="intro">{{OriginalProduct.intro|raw}}</div>
  142.                             </div>
  143.                         {% endif %}
  144.                         {% set reviewScore = OriginalProduct.getScore() %}
  145.                         {% if reviewScore is not empty and reviewScore > 0 and WebshopSettings.getEnableCardReviews() and OriginalProduct.type != 1 and OriginalProduct.type != 2 %}
  146.                         <div class="review-wrapper">
  147.                             <div class="review-rating">
  148.                                 {% set half_marked = null %}
  149.                                 {% for r in range( 0.5, 5, 0.5 ) %}
  150.                                     {% if r matches '/^\\d+$/' %}
  151.                                         {# full #}
  152.                                         {% if r <= ( reviewScore ) %}
  153.                                             {% if half_marked %}
  154.                                             {% else %}
  155.                                                 <i class="fas fa-fw fa-star on"></i>
  156.                                             {% endif %}
  157.                                         {% else %}
  158.                                             {# SOLID / ACTIVE #}
  159.                                             {% if half_marked %}
  160.                                             {% else %}
  161.                                                 <i class="far fa-fw fa-star"></i>
  162.                                             {% endif %}
  163.                                         {% endif %}
  164.                                         {% set half_marked = false %}
  165.                                     {% else %}
  166.                                         {# half #}
  167.                                         {% if ( reviewScore ) > r or( reviewScore ) < r %}
  168.                                         {% else %}
  169.                                             <i class="fas fa-fw fa-star-half-alt on"></i>
  170.                                             {% set half_marked = true %}
  171.                                         {% endif %}
  172.                                     {% endif %}
  173.                                 {% endfor %}
  174.                                 <span class="review-amount">({{OriginalProduct.getModeratedReviewsCount()}})</span>
  175.                             </div>
  176.                         </div>
  177.                         {% endif %}
  178.                     </div>
  179.                     <div class="card-bottom">
  180.                         <div class="card-col">
  181.                             {# {{dump(OriginalProduct.label)}} #}
  182.                             {% if show_price %}
  183.                                 <div class="pricing">
  184.                                     {{OriginalProduct.displayPrice(WebshopSettings, WebshopCustomer, app.user, true, false, null, null, false, false, null, (translator is defined ? translator : null))|trans_replace('webshop', language)|raw}}
  185.                                 </div>
  186.                             {% endif %}
  187.                         </div>
  188.                         <div class="card-col">
  189.                             {% if WebshopSettings.getB2b and WebshopSettings.hidePricesGuest %}
  190.                             {% else %}
  191.                                 {% if allow_cart or allow_list %}
  192.                                     {% if allow_cart and OriginalProduct.type != 1 and OriginalProduct.type != 2 %}
  193.                                         {% if OriginalProduct.canOrder %}
  194.                                             {% set cartimage = OriginalProduct.media is not empty ? '/' ~ OriginalProduct.media.first.getWebPath('small') : (WebshopSettings.getDefaultProductImage is not empty ? WebshopSettings.getDefaultProductImage : '/bundles/trinitywebshop/img/no-product-image.png') %}
  195.                                             <button data-cartimage="{{cartimage}}" data-carttitle="{{Product.label}}" data-cartintro="{{Product.intro}}" data-cartprice="{{Product.getDisplayPrice((WebshopSettings is defined ? WebshopSettings : null), WebshopCustomer, app.user)}}" type="button" data-id="{{OriginalProduct.id}}" class="btn order" data-catid="{{Category.id}}" title="Toevoegen aan winkelwagen">
  196.                                                 <i class="fa fa-shopping-cart"></i>
  197.                                                 <i class="fa fa-plus"></i>
  198.                                             </button>
  199.                                         {% else %}
  200.                                             <button type="button" disabled="disabled" data-id="{{OriginalProduct.id}}" class="btn btn-disabled" data-catid="{{Category.id}}" title="Niet op voorraad">
  201.                                                 <i class="fa fa-shopping-cart"></i>
  202.                                             </button>
  203.                                         {% endif %}
  204.                                     {% endif %}
  205.                                 {% endif %}
  206.                             {% endif %}
  207.                         </div>
  208.                     </div>
  209.                     {% set cardSpecs = OriginalProduct.getProductCardSpecValues() %}
  210.                     {% if cardSpecs is not empty %}
  211.                     <div class="card-footer">
  212.                         <div class="card-col">
  213.                             <table>
  214.                                 <tbody>
  215.                                     {% for label, value in cardSpecs %}
  216.                                         <tr>
  217.                                             <td>{{ label }}</td>
  218.                                             <td>{{ value }}</td>
  219.                                         </tr>
  220.                                     {% endfor %}
  221.                                 </tbody>
  222.                             </table>
  223.                         </div>
  224.                     </div>
  225.                     {% endif %}
  226.                     {#
  227.                     {% if OriginalProduct is defined and OriginalProduct.type == 1 %}
  228.                         <div id="multiple-options-available">
  229.                             {{'Meerdere varianten beschikbaar.'|trans}}
  230.                         </div>
  231.                     {% endif %}
  232.                     #}
  233.                 </div>
  234.             </a>
  235.         </div>
  236. {% endif %}
  237. {# {% endif %} #}