custom/plugins/WbfkBundles/src/Resources/views/storefront/element/wbfk-product-bundles.html.twig line 1

Open in your IDE?
  1. {% block wbfk_product_bundles %}
  2.     {% set bundleChildren = page.extensions.wbfkBundlesData ? page.extensions.wbfkBundlesData.bundleChildren : [] %}
  3.     {% set bundleParents = page.extensions.wbfkBundlesData ? page.extensions.wbfkBundlesData.bundleParents : [] %}
  4.     <div class="wbfk-product-bundles">
  5.         {% if bundleChildren.count > 0 %}
  6.             <h2>{{ 'wbfk-bundles.title-bundle-children' | trans }}</h2>
  7.             <div class="wbfk-product-bundles__bundle-child-grid">
  8.                 {% for bundleChild in bundleChildren %}
  9.                     <div class="wbfk-product-bundles__bundle-child">
  10.                         {% if bundleChild.quantity > 0 %}
  11.                             <div class="wbfk-product-bundles__bundle-child-quantity">
  12.                                 {{ bundleChild.quantity }}
  13.                             </div>
  14.                         {% endif %}
  15.                         {% sw_include '@Storefront/storefront/component/product/card/box.html.twig' with {
  16.                             'product': bundleChild.salesChannelChildProduct,
  17.                             'layout': 'standard',
  18.                             'displayMode': 'contain'
  19.                         } %}
  20.                     </div>
  21.                 {% endfor %}
  22.             </div>
  23.         {% endif %}
  24.         {% if bundleParents.count > 0 %}
  25.             {% set visibleItemsByDefault = 3 %}
  26.             <h2>{{ 'wbfk-bundles.title-bundle-parents' | trans }}</h2>
  27.             <div class="wbfk-product-bundles__bundle-parent-list">
  28.                 {% for bundleParent in bundleParents %}
  29.                     {% if loop.index == (visibleItemsByDefault + 1) %}
  30.                         <input type="checkbox"
  31.                                id="wbfk-product-bundles__unfold-checkbox"
  32.                                class="wbfk-product-bundles__unfold-checkbox">
  33.                         <label class="wbfk-product-bundles__unfold-label btn outline-blue btn-block"
  34.                                for="wbfk-product-bundles__unfold-checkbox">
  35.                             {{ 'wbfk-bundles.unfold-more-bundles' | trans({'%itemCount': bundleParents.count - visibleItemsByDefault}) }}
  36.                         </label>
  37.                     {% endif %}
  38.                     {% if loop.index > visibleItemsByDefault %}
  39.                         <div class="wbfk-product-bundles__unfold-container">
  40.                     {% endif %}
  41.                     <div class="wbfk-product-bundles__bundle-parent">
  42.                         <div class="wbfk-product-bundles__bundle-parent-summary">
  43.                             <span class="wbfk-product-bundles__bundle-parent-name">{{ bundleParent.salesChannelProduct.name }}</span>
  44.                             {% set totalChildrenPrice = 0 %}
  45.                             {% set totalParentPrice = bundleParent.salesChannelProduct.calculatedCheapestPrice.unitPrice %}
  46.                             {% for bundleChild in bundleParent.childBundleProducts %}
  47.                                 {% set totalChildrenPrice = totalChildrenPrice + (bundleChild.quantity * bundleChild.salesChannelChildProduct.calculatedCheapestPrice.unitPrice) %}
  48.                             {% endfor %}
  49.                             {% if totalChildrenPrice %}
  50.                                 {% set savedPercent = (1 - (totalParentPrice / totalChildrenPrice)) * 100 %}
  51.                             {% else %}
  52.                                 {% set savedPercent = null %}
  53.                             {% endif %}
  54.                             <div class="wbfk-product-bundles__bundle-parent-price">
  55.                                 <div class="product-badges">
  56.                                     <div class="badge badge-danger badge-discount">
  57.                                         <span>&#37;</span>
  58.                                     </div>
  59.                                 </div>
  60.                                 <div class="wbfk-product-bundles__bundle-parent-price-inner">
  61.                                     {% if savedPercent %}
  62.                                         <div class="wbfk-product-bundles__bundle-parent-price-savings">
  63.                                             {{ 'wbfk-bundles.bundle-parent-savings' | trans({'%totalChildrenPrice': (totalChildrenPrice|round(2)|currency), '%savedPercent': (savedPercent|round(2))  }) }}
  64.                                         </div>
  65.                                     {% endif %}
  66.                                     <div class="wbfk-product-bundles__bundle-parent-price-total">
  67.                                         {{ 'wbfk-bundles.bundle-parent-total' | trans({'%totalParentPrice': (totalParentPrice|currency)  }) }}
  68.                                     </div>
  69.                                 </div>
  70.                             </div>
  71.                             {% sw_include '@Storefront/storefront/component/product/card/action.html.twig' with {
  72.                                 'product': bundleParent.salesChannelProduct
  73.                             } %}
  74.                         </div>
  75.                         <div class="wbfk-product-bundles__bundle-child-grid wbfk-product-bundles__bundle-parent-children">
  76.                             {% for bundleChild in bundleParent.childBundleProducts %}
  77.                                 <div class="wbfk-product-bundles__bundle-child">
  78.                                     {% if bundleChild.quantity > 0 %}
  79.                                         <div class="wbfk-product-bundles__bundle-child-quantity">
  80.                                             {{ bundleChild.quantity }}
  81.                                         </div>
  82.                                     {% endif %}
  83.                                     {% sw_include '@Storefront/storefront/component/product/card/box.html.twig' with {
  84.                                         'product': bundleChild.salesChannelChildProduct,
  85.                                         'layout': 'standard',
  86.                                         'displayMode': 'contain'
  87.                                     } %}
  88.                                 </div>
  89.                             {% endfor %}
  90.                         </div>
  91.                     </div>
  92.                     {% if loop.index > visibleItemsByDefault %}
  93.                         {# Close div.wbfk-product-bundles__unfold-container #}
  94.                         </div>
  95.                     {% endif %}
  96.                 {% endfor %}
  97.             </div>
  98.         {% endif %}
  99.     </div>
  100. {% endblock %}