custom/plugins/EmovaWbTheme/src/Resources/views/storefront/component/product/card/compare-button.html.twig line 1

Open in your IDE?
  1. {% block frosh_product_compare_add_to_compare_box %}
  2.   {% set showIconOnly = config('FroshProductCompare.config.showIconOnly') %}
  3.   {# @var product \Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity #}
  4.   <div class="compare-button">
  5.     {% set addToCompareOptions = { productId: product.id, showIconOnly: showIconOnly, defaultText: 'froshProductCompare.general.addToCompare'|trans|sw_sanitize, addedText: 'froshProductCompare.general.removeFromCompare'|trans|sw_sanitize } %}
  6.     {% block frosh_product_compare_add_to_compare_button %}
  7.       <div style="display: flex; margin-bottom: 20px;">
  8.         <input id="checkCompare_{{id}}" class="custom-checkbox-custom-symbol" checkbox-id="{{id}}"  type="checkbox" name="scales">
  9.         <div style="display: table-cell; vertical-align: middle; line-height: 15px; margin-left: 7px; text-align: left; color:black;">
  10.             <span class="almarenaRegular" style="font-size:13px;">PRODUKT <br> VERGLEICHEN</span>
  11.         </div>
  12.     </div>
  13.       {% if showIconOnly %}
  14.         <button hidden id="checked_{{ id }}" data-add-to-compare-button="true" data-add-to-compare-button-options="{{ addToCompareOptions|json_encode }}" class="btn btn-block btn-compare" title="{{ 'froshProductCompare.general.addToCompare'|trans|striptags }}">{# {% sw_icon 'bag-product' style { 'size': 'sm', 'color': 'primary' } %} #}</button>
  15.       {% else %}
  16.         <button hidden id="checked_{{ id }}" data-add-to-compare-button="true" data-add-to-compare-button-options="{{ addToCompareOptions|json_encode }}" class="btn btn-block btn-compare" title="{{ 'froshProductCompare.general.addToCompare'|trans|striptags }}">{# {{ "froshProductCompare.general.addToCompare"|trans|sw_sanitize }} #}</button>
  17.       {% endif %}
  18.     {% endblock %}
  19.   </div>
  20.   <script>
  21.     (()=>{
  22.       const myInterval = setInterval(()=>{
  23.         if (!window.$) return;
  24.         clearInterval(myInterval);
  25.         $(()=>{
  26.           const storedList = localStorage.getItem("compare-widget-added-products");
  27.           if (storedList) {
  28.             const productList = JSON.parse(storedList);
  29.             const idToCheck = $('#checkCompare_{{id}}').attr("checkbox-id");
  30.             $('#checkCompare_{{id}}').prop('checked', productList.includes(idToCheck));
  31.           }
  32.           $('#checkCompare_{{id}}').change(()=>$('#checked_{{id}}').trigger('click'));
  33.         });
  34.       }, 100);
  35.     })();
  36.   </script>
  37. {% endblock %}