custom/plugins/theme/src/Resources/views/storefront/component/product/card/box.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/component/product/card/box.html.twig' %}
  2. {# add lazy load and hover img to generic box template #}
  3. {% block component_product_box_image_link_inner %}
  4.     {% if cover.url %}
  5.         {% set hoverImg = false %}
  6.         {% set hoverImgSrc = '' %}
  7.         {% if product.customFields.doncarne_product_custom_fields_listing_hover_img %}
  8.             {% set hoverImgId = product.customFields.doncarne_product_custom_fields_listing_hover_img %}
  9.             {% if context.context is defined %}
  10.                 {% set mediaCollection = searchMedia([hoverImgId], context.context) %}
  11.                 {% set media = mediaCollection.get(hoverImgId) %}
  12.             {% elseif context is defined %}
  13.                 {% set mediaCollection = searchMedia([hoverImgId], context) %}
  14.                 {% set media = mediaCollection.get(hoverImgId) %}
  15.             {% else %}
  16.                 {% for mediaItem in product.media %}
  17.                     {% if mediaItem.media.id == hoverImgId %}
  18.                         {% set media = mediaItem.media %}
  19.                     {% endif %}
  20.                 {% endfor %}
  21.             {% endif %}
  22.             
  23.             {% if media and media.url %}
  24.                 {% set hoverImgSrc = media.url %}
  25.                 {% set hoverImg = true %}
  26.             {% endif %}
  27.         {% endif %}
  28.         {% set attributes = {
  29.             'class': 'product-image is-'~displayMode,
  30.             'alt': (cover.translated.alt ?: name),
  31.             'title': (cover.translated.title ?: name),
  32.             'loading': 'lazy',
  33.             'data-hover-img': hoverImg ? '1' : '0',
  34.             'data-hover-img-source': hoverImgSrc
  35.         } %}
  36.         {% if displayMode == 'cover' or displayMode == 'contain' %}
  37.             {% set attributes = attributes|merge({ 'data-object-fit': displayMode }) %}
  38.         {% endif %}
  39.         {% block component_product_box_image_thumbnail %}
  40.            {{ parent() }}
  41.         {% endblock %}
  42.     {% else %}
  43.         {% block component_product_box_image_placeholder %}
  44.             <div class="product-image-placeholder product-image is-standard">
  45.                 {% sw_icon 'placeholder' style {
  46.                     'size': 'fluid'
  47.                 } %}
  48.             </div>
  49.         {% endblock %}
  50.     {% endif %}
  51. {% endblock %}
  52. {% block component_product_box_wishlist_action %}
  53.     {# default shopware only if plugin not active #}
  54.     {% if not config('CoeWishlistSw6.config.wishlistButtonOnListing') %}
  55.         {% if controllerName !== "Wishlist" %}
  56.             {{ parent() }}
  57.             {# on wishlist page: show remove button #}
  58.         {% else %}
  59.             <div class="product-wishlist product-wishlist-remove">
  60.                 {% block component_product_wishlist_remove_form %}
  61.                     {% set size = size ?? 'md' %}
  62.                     <form action="{{ path('frontend.wishlist.product.delete', {'id': id}) }}"
  63.                             method="post"
  64.                             class="product-wishlist-form"
  65.                             data-form-csrf-handler="true">
  66.                         {% block component_product_box_wishlist_remove_csrf %}
  67.                             {{ sw_csrf('frontend.wishlist.product.delete') }}
  68.                         {% endblock %}
  69.                         {% block component_product_wishlist_remove_redirect %}
  70.                             <input type="hidden"
  71.                                     name="redirectTo"
  72.                                     value="frontend.wishlist.page"/>
  73.                         {% endblock %}
  74.                         {% block component_product_wishlist_remove_submit %}
  75.                             <button type="submit" class="btn product-wishlist-btn product-wishlist-btn-remove">
  76.                                 {% sw_icon 'x' style { 'class': 'icon-wishlist icon-wishlist-remove', 'size': size, 'pack': 'solid' } %}
  77.                             </button>
  78.                         {% endblock %}
  79.                     </form>
  80.                 {% endblock %}
  81.             </div>
  82.         {% endif %}
  83.     {% endif %}
  84. {% endblock %}
  85. {% block component_product_box_info %}
  86.     {# Add product number reference -- used in app/storefront/src/js/product-listing-rating.plugin.js && controller url #}
  87.     <div class="product-info">
  88.         {% block component_product_box_name %}
  89.             {{ parent() }}
  90.             <a
  91.                 data-rating-url="{{ path('frontend.product.rating', {'productNumber': product.productNumber }) }}"
  92.                 href="{{ seoUrl('frontend.detail.page', {'productId': product.id}) }}#review-tab-pane"
  93.             ></a>
  94.             {% if product.getExtension("doncarneCutProperties").all()|first %}
  95.                 {% sw_include '@Storefront/solution360/cut-product-property-image.html.twig' with {media: product.getExtension("doncarneCutProperties").all()|first.media} only %}
  96.             {% endif %}
  97.             <span class="product-unit-label">
  98.                 {% if product.purchaseUnit %}
  99.                     {{ "listing.boxUnitLabel"|trans|sw_sanitize }} {{product.purchaseUnit}} {{product.unit.translated.name}}
  100.                 {% endif %}
  101.                 {% if product.translated.packUnit %}
  102.                     {% if product.purchaseUnit %}, {% endif %}{{product.translated.packUnit}}
  103.                 {% endif %}
  104.             </span>
  105.         {% endblock %}
  106.         {% block component_product_box_rating %}
  107.             {% if config('core.listing.showReview') %}
  108.                 <div class="product-rating">
  109.                     {% if true or product.ratingAverage %}
  110.                         {% sw_include '@Storefront/storefront/component/review/rating.html.twig' with {
  111.                             points: product.ratingAverage,
  112.                             style: 'text-primary'
  113.                         } %}
  114.                         <span class="point-rating__details">{{product.ratingAverage}}/5.00</span>
  115.                     {% endif %}
  116.                 </div>
  117.             {% endif %}
  118.         {% endblock %}
  119.         {% block component_product_box_variant_characteristics %}
  120.             {% sw_include '@Storefront/solution360/product-usps-listing.html.twig' with { product: product }%}
  121.         {% endblock %}
  122.         {% block component_product_box_description %}
  123.         {% endblock %}
  124.         {% block component_product_box_price %}
  125.             {{ parent() }}
  126.         {% endblock %}
  127.         {# % sw_include '@Storefront/solution360/special-product-properties.html.twig' with {specialProperties: product.getExtension("doncarneSpecialProperties").all()} % #}
  128.         {% block component_product_box_action %}
  129.         {% endblock %}
  130.         {# this block depends on whether or not third party plugin installed #}
  131.         {% if config('CoeWishlistSw6.config.wishlistButtonOnListing') %}
  132.             {# CoeWishlistSw6 is active and adjusted #}
  133.             {% sw_include '@Storefront/storefront/component/wishlist/button/add-note.html.twig'
  134.                 with {
  135.                     additionalClass: 'product-card__wishlist-btn'
  136.                 }
  137.             %}
  138.         {% endif %}
  139.     </div>
  140. {% endblock %}