templates/twig-extension/render_product_card.html.twig line 1

Open in your IDE?
  1. {% set _basket_storage = app.session.get('mldev-cart-storage', []) %}
  2. {% set _basket_amount = _basket_storage[product_item.id]|default(0) %}
  3. {% set product_id =  product_item.id %}
  4. {% set product_name =  product_item.name|default(product_item.product.name) %}
  5. {% set product_url = path('mldev-front-product-show', { 'id': product_item.id }) %}
  6. {% set product_price = product_item.price|number_format(0, '', ' ')  %}
  7. {% set product_price_old = product_item.priceOld|number_format(0, '', ' ')  %}
  8. {% set product_price_unit = '₽' %}
  9. {% set product_volume = product_item.volume %}
  10. {% set product_volume_unit = product_item.volumeUnit %}
  11. {% if product_item.defaultImage %}
  12.     {% set image = asset(product_item.defaultImage.uri) %}
  13. {% elseif product_item.getAvailableImages()|length %}
  14.     {% set image = asset(product_item.defaultImage.uri) %}
  15. {% else %}
  16.     {% set image = asset('img/no_image.jpg') %}
  17. {% endif %}
  18. {% set product_info = {
  19.     id: product_id,
  20.     img: image,
  21.     imgAlt: product_name,
  22.     title: product_name,
  23.     cost: product_price,
  24.     costUnit: product_price_unit,
  25.     discount: product_price_old,
  26.     volume: product_volume,
  27.     volumeUnit: product_volume_unit,
  28.     link: product_url
  29. } %}
  30. <div data-product-id="{{ product_id }}" data-product-info="{{ product_info|json_encode }}" class="product-item">
  31.     <div class="product-item__header">
  32.         <button class="product-item__fav btn-control btn-control-fav" data-favorite type="button">
  33.             <span class="btn-control__icon">
  34.                 <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
  35.                     <path d="M11.4769 20.0849C10.673 19.0023 9.62237 17.787 8.59332 16.9473C8.25868 16.6742 7.8048 16.0156 7.56804 15.6399C7.29524 15.207 6.62317 14.4126 6.15828 14.2018C5.63801 13.966 5.14534 12.9968 4.87668 12.5096C4.54878 11.9149 3.99567 11.4029 3.58796 10.8681C2.99986 10.0968 2.31606 9.43 2.12836 8.37693C1.95576 7.40857 1.8957 6.57773 2.34908 5.70416C2.83386 4.77007 3.53159 4.40876 4.42812 3.97557C5.91505 3.25709 8.66497 2.88765 10.1953 3.7141C10.5313 3.89555 10.859 4.15402 11.1565 4.39682C11.3678 4.56928 11.7155 5.24141 11.9326 5.30469C12.115 5.35786 12.6796 4.72702 12.9508 4.66555C13.3374 4.57791 13.7216 4.3088 14.1042 4.13535C16.0454 3.25525 19.7732 2.06428 21.4022 4.20072C21.9168 4.87563 21.986 6.29744 21.986 7.11317C21.986 8.26121 22.0956 9.42618 21.7012 10.5123C21.4479 11.21 20.9329 12.0078 20.4196 12.5314C19.1496 13.8269 17.7324 14.9821 16.4467 16.2645C15.213 17.495 13.6926 18.412 12.374 19.5329C11.8811 19.9519 11.2545 20.7212 10.708 21" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/>
  36.                 </svg>
  37.             </span>
  38.         </button>
  39.         {% if product_item.isNew %}
  40.             <div class="product-item__new">
  41.                 <img src="/img/icons/new.svg" alt="">
  42.             </div>
  43.         {% endif %}
  44.         {% if product_item.isSale %}
  45.             <div class="product-item__sale">
  46.                 <img src="/img/icons/sale.svg" alt="">
  47.             </div>
  48.         {% endif %}
  49.         <a class="product-item__img" href="{{ product_url }}">
  50.             <img src="{{ image }}" alt="{{ product_name }}" />
  51.         </a>
  52.     </div>
  53.     {% if options.single_display_variant %}
  54.         <div class="product-item__meta">
  55.     {% endif %}
  56.         <div class="product-item__body">
  57.             {% if options.single_display_variant %}
  58.                 <div class="product-item__badges">
  59.                     {% if product_item.isNew %}
  60.                         <div class="product-item__new">
  61.                             <img src="/img/icons/new.svg" alt="">
  62.                         </div>
  63.                     {% endif %}
  64.                     {% if product_item.isSale %}
  65.                         <div class="product-item__sale">
  66.                             <img src="/img/icons/sale.svg" alt="">
  67.                         </div>
  68.                     {% endif %}
  69.                 </div>
  70.             {% endif %}
  71.             <a class="product-item__title" href="{{ product_url }}">
  72.                 {{ product_name }}
  73.             </a>
  74.             {% if options.single_display_variant %}
  75.                 <div class="product-item__description">
  76.                     {{ product_item.product.extraFields['short-descr-in-single-display-variant']|default|raw }}
  77.                 </div>
  78.             {% endif %}
  79.             <div class="product-item__volume">
  80.                 <span class="product-item__volume-num"> {{ product_volume }} </span>
  81.                 <span class="product-item__volume-unit"> {{ product_volume_unit }}  </span>
  82.             </div>
  83.         </div>
  84.         <div class="product-item__footer {{ _basket_amount ? 'active-counter' }}" data-counter>
  85.             <div class="product-item__price">
  86.                 <div class="product-item__cost">
  87.                     <span class="product-item__cost-num{% if product_item.priceOld > 0 %} product-item__cost-num-with-old{% endif %}"> {{ product_item.price|number_format(0, '', ' ') }} </span>
  88.                     <span class="product-item__cost-unit"> {{ product_price_unit }} </span>
  89.                 </div>
  90.                 {% if product_item.priceOld > 0 %}
  91.                     <div class="product-item__discount"> {{ product_item.priceOld|number_format(0, '', ' ') }} </div>
  92.                 {% endif %}
  93.             </div>
  94.             {% if product_item.amount > 0 %}
  95.                 <div class="product-item__control">
  96.                     <button class="product-counter__control btn-control product-add" data-action-add="" type="button">
  97.                       <span class="product-add__text"></span>
  98.                       <span class="btn-control__icon">
  99.                         <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
  100.                             <circle cx="24" cy="27" r="18" fill="white"/>
  101.                             <path d="M15.3888 19.7004C15.3888 21.3353 15.4427 22.9589 15.2376 24.5789C15.0708 25.8966 14.9496 27.8908 15.2916 29.1663C15.4992 29.9405 14.9044 34 15.8749 34C18.7199 34 21.5243 33.5972 24.3971 33.5972C26.7877 33.5972 29.1784 33.5972 31.5691 33.5972C32.3228 33.5972 33.1619 33.8411 33.859 33.7986C34.2818 33.7728 33.6245 32.6506 33.5673 32.4335C33.1272 30.7618 33.011 28.9669 32.8004 27.253C32.5499 25.2139 32.2298 23.2175 32.3036 21.155C32.3126 20.9033 32.8197 19.2088 32.3792 19.1074C31.3583 18.8724 30.0174 19.0962 28.9768 19.0962C26.7834 19.0962 24.5806 19.0349 22.388 19.0962C20.8135 19.1403 19.1158 19.2836 17.5383 19.4879C16.6589 19.6017 15.8415 19.4099 15 19.7004" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/>
  102.                             <path d="M20.5 22C20.5 20.921 20 20.0845 20 18.9412C20 18.0196 20 17.098 20 16.1765C20 14.2428 21.5057 13 23.1944 13C24.1502 13 26.1476 15.9948 26.25 16.9706C26.3114 17.5558 26.6701 20.7665 27 20.9412" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/>
  103.                         </svg>
  104.                       </span>
  105.                     </button>
  106.                     <div class="product-counter-wrapper">
  107.                         <a href="/cart" class="product-add product-add-active">
  108.                             <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
  109.                                 <path d="M16.7427 27.9628C17.972 29.192 19.2731 30.3269 20.4921 31.5459C21.2793 32.3331 21.923 32.2847 22.9762 32.2847C23.3345 32.2847 23.6991 32.3045 24.0567 32.2847C24.4177 32.2646 24.5715 31.694 24.7309 31.4351C25.525 30.1446 26.0593 28.7234 26.8826 27.4272C28.032 25.6174 29.4019 23.903 30.3641 21.9786C30.664 21.3788 30.8534 20.7023 31.2414 20.1501C31.697 19.5018 32.5343 17.363 32.5343 18.1554" stroke="black" stroke-width="2.5" stroke-linecap="round"/>
  110.                             </svg>
  111.                         </a>
  112.                         <div class="product-counter">
  113.                             <button class="product-counter__control btn-control btn-control-minus-small" data-decrease-amount type="button">
  114.                                 <span class="btn-control__icon">
  115.                                     <svg class="icon icon-minus-small">
  116.                                         <use xlink:href="/img/sprite.svg#icon-minus-small"></use>
  117.                                     </svg>
  118.                                 </span>
  119.                             </button>
  120.                             <div class="product-counter__info">
  121.                                 <span class="product-counter__num" data-amount="{{ _basket_amount }}">{{ _basket_amount }}</span>
  122.                                 <span class="product-counter__unit">шт</span>
  123.                             </div>
  124.                             <button class="product-counter__control btn-control btn-control-plus-small" data-increase-amount type="button">
  125.                                 <span class="btn-control__icon">
  126.                                     <svg class="icon icon-plus-small">
  127.                                         <use xlink:href="/img/sprite.svg#icon-plus-small"></use>
  128.                                     </svg>
  129.                                 </span>
  130.                             </button>
  131.                         </div>
  132.                     </div>
  133.                 </div>
  134.             {% else %}
  135.                 <div class="product-out-of-stock">скоро в продаже</div>
  136.             {% endif %}
  137.         </div>
  138.     {% if options.single_display_variant %}
  139.         </div>
  140.     {% endif %}
  141. </div>