templates/app/Group/product.html.twig line 1

Open in your IDE?
  1. {% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
  2. {% set twig_img_path = absolute_url('/media/image/') %}
  3. {% set imageSource = product.images|default(0) ? twig_img_path ~ product.images[0].path : "" %}
  4. {% set productVariant = product.type == constant('App\\Entity\\Core\\Product::BY_BATCH') ? (product.variants|length > 1 ? product.variants[1] : null) : product.variants.first %}
  5. {% if productVariant|default(0) %}
  6.     {% set price = productVariant.channelPricings.first.price %}
  7.     {% set originalPrice = productVariant.channelPricings.first.originalPrice %}
  8.     {% set productVariantShowPath = path('app_product_variant_show', {'_locale': app.request.locale, 'groupCode': group.code, 'productVariantCode': productVariant.code}) %}
  9.     <div class="col-sm-3 col-md-3 col-xs-12 mb-0-5r mx-0">
  10.         <div class="card">
  11.             <div class="card-img-box">
  12.                 {% if imageSource %}
  13.                     <a href="{{ productVariantShowPath }}">
  14.                         <img alt="Card image" class="img-fluid" src="{{ imageSource }}">
  15.                     </a>
  16.                 {% else %}
  17.                     <a href="{{ productVariantShowPath }}">
  18.                         <img src="{{ asset("build/images/sin-imagen.jpg") }}" class="img-fluid"/>
  19.                     </a>
  20.                 {% endif %}
  21.                 <a class="btn-see-product py-1 ff-os-light fs-12" href="{{ productVariantShowPath }}">
  22.                     {{ "group.product_variant.buttons.show.label"|trans }}
  23.                 </a>
  24.                 {% if productVariant.product.canBeSold and originalPrice|default(0) and originalPrice > price %}
  25.                     <label class="btn-discount py-1 ff-os-light">
  26.                         -{{ (((originalPrice - price) * 100) / originalPrice)|round }}%
  27.                     </label>
  28.                 {% endif %}
  29.             </div>
  30.             <div class="card-body">
  31.                 {# <div class="d-flex">
  32.                     <h6 class="ct-blue ff-os-light text-truncate mt-3 mb-2">
  33.                         {{ group.name }}
  34.                     </h6>
  35.                 </div> #}
  36.                 <div class="d-flex">
  37.                     <h6 class="ct-blue ff-os-semibold mt-3 mb-2">
  38.                         {{ product.name }}
  39.                     </h6>
  40.                 </div>
  41.                 {% if productVariant.product.canBeSold %}
  42.                     <div class="d-flex">
  43.                         <h6 class="ct-blue ff-os-bold text-truncate fs-18 {% if originalPrice|default(0) and originalPrice > price %} ct-red m-0 {% else %} mb-4 {% endif %}">
  44.                             {{ money.convertAndFormat(price) }}
  45.                         </h6>
  46.                     </div>
  47.                     {% if originalPrice|default(0) and originalPrice > price %}
  48.                         <p class="td-lt ct-darkgray ff-os-regular fs-14">
  49.                             {{ money.convertAndFormat(originalPrice) }}
  50.                         </p>
  51.                     {% endif %}
  52.                 {% endif %}
  53.             </div>
  54.         </div>
  55.     </div>
  56. {% endif %}