custom/plugins/KkTheme/src/Resources/views/storefront/component/product/card/action.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/component/product/card/action.html.twig' %}
  2. {% block component_product_box_action_inner %}
  3.     {% set id = product.id %}
  4.     <div class="product-action">
  5.         {% set isAvailable = not product.isCloseout or (product.availableStock >= product.minPurchase) %}
  6.         {% set displayFrom = product.calculatedPrices.count > 1 %}
  7.         {# % set displayBuyButton = isAvailable and not displayFrom and product.childCount <= 0 % #}
  8.         {% set displayBuyButton = isAvailable and product.childCount <= 0 %}
  9.         {% if displayBuyButton and config('core.listing.allowBuyInListing') %}
  10.             {% block component_product_box_action_buy %}
  11.                 {# @var product \Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity #}
  12.                 <form action="{{ path('frontend.checkout.line-item.add') }}"
  13.                       method="post"
  14.                       class="buy-widget"
  15.                       data-add-to-cart="true">
  16.                     {% block component_product_box_action_buy_csrf %}
  17.                         {{ sw_csrf('frontend.checkout.line-item.add') }}
  18.                     {% endblock %}
  19.                     {% block component_product_box_action_form %}
  20.                         {% block component_product_box_action_buy_redirect_input %}
  21.                             {# fallback redirect back to detail page is deactivated via js #}
  22.                             <input type="hidden"
  23.                                    name="redirectTo"
  24.                                    value="frontend.detail.page">
  25.                             <input type="hidden"
  26.                                    name="redirectParameters"
  27.                                    data-redirect-parameters="true"
  28.                                    value='{"productId": "{{ product.id }}"}'>
  29.                         {% endblock %}
  30.                         {% block page_product_detail_buy_product_buy_info %}
  31.                             <input type="hidden"
  32.                                    name="lineItems[{{ id }}][id]"
  33.                                    value="{{ id }}">
  34.                             <input type="hidden"
  35.                                    name="lineItems[{{ id }}][referencedId]"
  36.                                    value="{{ id }}">
  37.                             <input type="hidden"
  38.                                    name="lineItems[{{ id }}][type]"
  39.                                    value="product">
  40.                             <input type="hidden"
  41.                                    name="lineItems[{{ id }}][stackable]"
  42.                                    value="1">
  43.                             <input type="hidden"
  44.                                    name="lineItems[{{ id }}][removable]"
  45.                                    value="1">
  46.                                    {# <input type="hidden"
  47.                                    name="lineItems[{{ id }}][quantity]"
  48.                                    value="{{ product.minPurchase }}"> #}
  49.                         {% endblock %}
  50.                         {% block page_product_detail_product_buy_meta %}
  51.                             <input type="hidden"
  52.                                    name="product-name"
  53.                                    value="{{ product.translated.name }}">
  54.                         {% endblock %}
  55.                         {% block page_product_detail_product_buy_button %}
  56.                             {# @deprecated tag:v6.5.0 - Bootstrap v5 removes `btn-block` class, use `d-grid` wrapper instead #}
  57.                             <div class="calc-block">
  58.                             {# { dump(product.calculatedPrice.unitPrice) } #}
  59.                             {# { dump(product.calculatedCheapestPrice.unitPrice) } #}
  60.                             {# { dump(product.calculatedPrices.elements[0].unitPrice) } #}
  61.                             
  62.                             {% set purchasePrice = 0 %}
  63.                             {% if product.calculatedPrice.unitPrice and product.calculatedPrice.unitPrice != 0 %}
  64.                                 {% set purchasePrice = product.calculatedPrice.unitPrice %}
  65.                             {% endif %}
  66.                             {% if product.calculatedPrices.elements[0].unitPrice and product.calculatedPrice.unitPrice != 0 %}
  67.                                 {% set purchasePrice = product.calculatedPrices.elements[0].unitPrice %}
  68.                             {% endif %}
  69.                             {% if product.calculatedCheapestPrice.unitPrice and product.calculatedCheapestPrice.unitPrice != 0 %}
  70.                                 {% set purchasePrice = product.calculatedCheapestPrice.unitPrice %}
  71.                             {% endif %}
  72.                             <input type="hidden" name="minPurchase" class="calc-min-purchase" value="{{ product.minPurchase }}" />
  73.                             <input type="hidden" name="maxPurchase" class="calc-max-purchase" value="{{ product.maxPurchase }}" />
  74.                             <input type="hidden" name="purchaseStep" class="calc-purchase-step" value="{{ product.purchaseSteps }}" />
  75.                             {% if product.calculatedPrices|length > 1 %}
  76.                                 {% set breakloop = false %}
  77.                                 {% for price in product.calculatedPrices %}
  78.                                     {% if not breakloop %}
  79.                                         {% set abStaffel = product.minPurchase %}
  80.                                         {% if loop.index > 1 %}
  81.                                             {% set idx = loop.index - 2 %}
  82.                                             {% set pArr = product.calculatedPrices %}
  83.                                             {% set abStaffel = pArr.elements[idx].quantity + 1 %}
  84.                                             {% if abStaffel >= product.minPurchase %}
  85.                                                 {% set purchasePrice = price.unitPrice %}
  86.                                                 {% set breakloop = true %}
  87.                                             {% endif %}
  88.                                         {% endif %}
  89.                                     {% endif %}
  90.                                 {% endfor %}
  91.                             {% endif %}
  92.                             
  93.                             {% set totalPrice = product.minPurchase * purchasePrice %}
  94.                             <input type="hidden" name="purchasePrice" class="calc-purchase-price" value="{{ purchasePrice }}" />
  95.                             <input type="hidden" name="totalPrice" class="calc-purchase-total" value="{{ totalPrice }}" />
  96.                             <div class="calc-result-block">
  97.                                 <span class="calc-cur-amount">{{ product.minPurchase }}</span> x 
  98.                                 <span class="calc-cur-price">{{ purchasePrice|number_format(2,",",".") }} &euro;</span> = 
  99.                                 <span class="calc-cur-total">{{ totalPrice|number_format(2,",",".") }} &euro;{{ "general.star"|trans|sw_sanitize }}</span>
  100.                             </div>
  101.                             {% if feature('v6.5.0.0') %}
  102.                                 <div class="d-grid">
  103.                                     <button class="btn btn-buy"
  104.                                             title="{{ "listing.boxAddProduct"|trans|striptags }}">
  105.                                         {{ "listing.boxAddProduct"|trans|sw_sanitize }}
  106.                                     </button>
  107.                                 </div>
  108.                             {% else %}
  109.                                 <button type="button" class="btn btn-primary calc-btn calc-btn-down">-</button>
  110.                                 <input name="lineItems[{{ id }}][quantity]" 
  111.                                     value="{{ product.minPurchase }}" 
  112.                                     class="product-details-quantity-select calc-input-qty">
  113.                                 <button type="button" class="btn btn-primary calc-btn calc-btn-up">+</button>
  114.                                 <button class="btn btn-buy"
  115.                                         title="{{ "listing.boxAddProduct"|trans|striptags }}">
  116.                                     {% sw_icon 'cart' %}
  117.                                 </button>                           
  118.                             {% endif %}
  119.                             
  120.                             </div>
  121.                         {% endblock %}
  122.                     {% endblock %}
  123.                 </form>
  124.             {% endblock %}
  125.         {% else %}
  126.             {% block component_product_box_action_detail %}
  127.                 {# @deprecated tag:v6.5.0 - Bootstrap v5 removes `btn-block` class, use `d-grid` wrapper instead #}
  128.                 {% if feature('v6.5.0.0') %}
  129.                     <div class="d-grid">
  130.                         <a href="{{ seoUrl('frontend.detail.page', {'productId': id}) }}"
  131.                            class="btn btn-light"
  132.                            title="{{ "listing.boxProductDetails"|trans|striptags }}">
  133.                             {{ "listing.boxProductDetails"|trans|sw_sanitize }}
  134.                         </a>
  135.                     </div>
  136.                 {% else %}
  137.                     <div class="calc-result-block">&nbsp;</div>
  138.                     <a href="{{ seoUrl('frontend.detail.page', {'productId': id}) }}"
  139.                        class="btn btn-block btn-light"
  140.                        title="{{ "listing.boxProductDetails"|trans|striptags }}">
  141.                         {{ "listing.boxProductDetails"|trans|sw_sanitize }}
  142.                     </a>
  143.                 {% endif %}
  144.             {% endblock %}
  145.         {% endif %}
  146.     </div>
  147.     {% block component_product_box_action_meta %}
  148.         <input type="hidden"
  149.                name="product-name"
  150.                value="{{ product.translated.name }}">
  151.         <input type="hidden"
  152.                name="product-id"
  153.                value="{{ id }}">
  154.     {% endblock %}
  155. {% endblock %}