themes/BootstrapChildTheme/SyliusShopBundle/views/Product/Box/_content.html.twig line 1

Open in your IDE?
  1. {% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
  2. {% set variant = product|sylius_resolve_variant %}
  3. {% set hasDiscount = variant ? variant|sylius_has_discount({'channel': sylius.channel}) : null %}
  4. {% set tagAttributes = product.attributesByLocale(app.request.locale, app.request.defaultLocale, sylius_base_locale)|filter(attribute => attribute.code == 'tag1' or attribute.code == 'tag2')|sort_by('attribute.position') %}
  5. {% set discount = variant ? money.calculateDiscount(variant, {'channel': sylius.channel, 'zone': sylius.channel.defaultTaxZone}) : null %}
  6. {% set tier_prices = variant ? variant.getTierPricesForChannel(sylius.channel, sylius.customer) : null %}
  7. {% set enabledVariants = product.enabledVariants %}
  8. <div class="product{% if h_100 is defined and h_100 %} h-100{% endif %} js-select-product" {{ sylius_test_html_attribute('product') }}
  9.     {# GA4 DATA ATTRIBUTES #}
  10.      data-item-id="{{ variant ? variant.code : product.code }}"
  11.      data-item-name="{{ product.name|escape('html_attr') }}"
  12.      data-item-category="{{ product.mainTaxon ? product.mainTaxon.name|escape('html_attr') : 'General' }}"
  13.     {# Cena: berieme minPrice ak existuje, inak cenu variantu. Delíme 100000 podľa tvojho nastavenia #}
  14.      data-price="{{ (product.minPrice ?: (variant ? variant.channelPricings.first.price : 0)) / 100000 }}"
  15.      data-quantity="{{ product.minQuantity ?: 1 }}"
  16.      data-index="{{ loop.index0|default(0) }}"
  17.      data-item-list-id="{{ product.mainTaxon ? product.mainTaxon.code|escape('html_attr') : 'category_page' }}"
  18.      data-item-list-name="{{ product.mainTaxon ? product.mainTaxon.name|escape('html_attr') : 'Category Page' }}"
  19. >
  20.     <div class="product-image-wrap">
  21.         <a class="product-image-link" href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}">
  22.             {% if hasDiscount %}
  23.                 <span class="labels-wrap">
  24.                     <span class="discount-content">
  25.                         <span class="label">-{{ discount }}%</span>
  26.                     </span>
  27.                 </span>
  28.             {% endif %}
  29.             {% include '@SyliusShop/Product/_mainImage.html.twig' with {'product': product, 'class': 'card-img-top'} %}
  30.             {% if product.labels %}
  31.                 <span class="labels-bottom-wrap">
  32.                     <span class="labels-content">
  33.                         {% for label in product.labels %}
  34.                             {% if label.code != 'top_all_categories' %}
  35.                                 <span class="label {{ label.code -}}">{{- label.name -}}</span>
  36.                             {% endif %}
  37.                         {% endfor %}
  38.                     </span>
  39.                 </span>
  40.             {% endif %}
  41.         </a>
  42.     </div>
  43.     <div class="product-content">
  44.         <h6 class="product-name fw-medium" {{ sylius_test_html_attribute('product-name', product.name) }}>
  45.             <a class="link-heading stretched-link" href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}">{{ product.name }}</a>
  46.         </h6>
  47.         <div class="product-description">
  48.             {% if product.shortDescription %}
  49.                 {{ product.shortDescription|striptags|unescape|u.truncate(100, '...', false) }}
  50.             {% else %}
  51.                 {{ product.description|striptags|unescape|u.truncate(100, '...', false) }}
  52.             {% endif %}
  53.         </div>
  54.     </div>
  55.     <div class="product-bottom">
  56.         {% if not product.enabledVariants.empty() %}
  57.             <div class="product-price-wrap">
  58.                 {% if product.minPrice %}
  59.                     <span class="text-nowrap">
  60.                         <span class="product-price-from cfs-8">{{ 'app.ui.price_from'|trans }}</span>
  61.                         <span class="product-price min-price cfs-5" {{ sylius_test_html_attribute('product-price') }}>{{ money.convertAndFormatSpecial(product.minPrice, {'divisor': 100000, 'scale': 3 }) }}</span>
  62.                     </span>
  63.                     {% if product.maxPrice %}
  64.                         <span class="text-nowrap">
  65.                             <span class="product-price-from cfs-8">{{ 'app.ui.price_to'|trans }}</span>
  66.                             <span class="product-price min-price cfs-5" {{ sylius_test_html_attribute('product-price') }}>{{ money.convertAndFormatSpecial(product.maxPrice, {'divisor': 100000, 'scale': 3 }) }}</span>
  67.                         </span>
  68.                     {% endif %}
  69.                 {% elseif enabledVariants|length == 1 %}
  70.                     {% if hasDiscount %}<span class="product-original-price cfs-8">{{ money.calculateOriginalPriceWithoutTax(variant, {'divisor': 100000, 'scale': 3, 'channel': sylius.channel, 'zone': sylius.channel.defaultTaxZone}) }}</span>{% endif %}
  71.                     <span class="product-price cfs-5" {{ sylius_test_html_attribute('product-price') }}>{{ money.calculatePrice(product|sylius_resolve_variant) }}</span>
  72.                 {% endif %}
  73.             </div>
  74.         {% endif %}
  75.         {% if product.minQuantity %}
  76.             <div class="product-min-quantity cfs-9">{{ 'app.product_box.min_qty'|trans({ '%qty%': product.minQuantity }) }}</div>
  77.         {% endif %}
  78.     </div>
  79. </div>