src/Storefront/Resources/views/storefront/component/product/card/action.html.twig line 1

  1. {% block component_product_box_action_inner %}
  2.     {% set id = product.id %}
  3.     <div class="product-action">
  4.         {% set isAvailable = not product.isCloseout or (product.availableStock >= product.minPurchase) %}
  5.         {% set displayFrom = product.calculatedPrices.count > 1 %}
  6.         {% set displayBuyButton = isAvailable and not displayFrom and product.childCount <= 0 %}
  7.         {% if displayBuyButton and config('core.listing.allowBuyInListing') %}
  8.             {% block component_product_box_action_buy %}
  9.                 {# @var product \Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity #}
  10.                 <form action="{{ path('frontend.checkout.line-item.add') }}"
  11.                       method="post"
  12.                       class="buy-widget"
  13.                       data-add-to-cart="true">
  14.                     {% block component_product_box_action_form %}
  15.                         {% block component_product_box_action_buy_redirect_input %}
  16.                             {# fallback redirect back to detail page is deactivated via js #}
  17.                             <input type="hidden"
  18.                                    name="redirectTo"
  19.                                    value="frontend.detail.page">
  20.                             <input type="hidden"
  21.                                    name="redirectParameters"
  22.                                    data-redirect-parameters="true"
  23.                                    value='{"productId": "{{ product.id }}"}'>
  24.                         {% endblock %}
  25.                         {% block page_product_detail_buy_product_buy_info %}
  26.                             <input type="hidden"
  27.                                    name="lineItems[{{ id }}][id]"
  28.                                    value="{{ id }}">
  29.                             <input type="hidden"
  30.                                    name="lineItems[{{ id }}][referencedId]"
  31.                                    value="{{ id }}">
  32.                             <input type="hidden"
  33.                                    name="lineItems[{{ id }}][type]"
  34.                                    value="product">
  35.                             <input type="hidden"
  36.                                    name="lineItems[{{ id }}][stackable]"
  37.                                    value="1">
  38.                             <input type="hidden"
  39.                                    name="lineItems[{{ id }}][removable]"
  40.                                    value="1">
  41.                             <input type="hidden"
  42.                                    name="lineItems[{{ id }}][quantity]"
  43.                                    value="{{ product.minPurchase }}">
  44.                         {% endblock %}
  45.                         {% block page_product_detail_product_buy_meta %}
  46.                             <input type="hidden"
  47.                                    name="product-name"
  48.                                    value="{{ product.translated.name }}">
  49.                         {% endblock %}
  50.                         {% block page_product_detail_product_buy_button %}
  51.                             <div class="d-grid">
  52.                                 <button class="btn btn-buy"
  53.                                         title="{{ "listing.boxAddProduct"|trans|striptags }}">
  54.                                     {{ "listing.boxAddProduct"|trans|sw_sanitize }}
  55.                                 </button>
  56.                             </div>
  57.                         {% endblock %}
  58.                     {% endblock %}
  59.                 </form>
  60.             {% endblock %}
  61.         {% else %}
  62.             {% block component_product_box_action_detail %}
  63.                 <div class="d-grid">
  64.                     <a href="{{ seoUrl('frontend.detail.page', {'productId': id}) }}"
  65.                        class="btn btn-light"
  66.                        title="{{ "listing.boxProductDetails"|trans|striptags }}">
  67.                         {{ "listing.boxProductDetails"|trans|sw_sanitize }}
  68.                     </a>
  69.                 </div>
  70.             {% endblock %}
  71.         {% endif %}
  72.     </div>
  73.     {% block component_product_box_action_meta %}
  74.         <input type="hidden"
  75.                name="product-name"
  76.                value="{{ product.translated.name }}">
  77.         <input type="hidden"
  78.                name="product-id"
  79.                value="{{ id }}">
  80.     {% endblock %}
  81. {% endblock %}