vendor/shopware/storefront/Resources/views/storefront/page/product-detail/buy-widget-form.html.twig line 1

Open in your IDE?
  1. {% block page_product_detail_buy_form_inner %}
  2.     {# @var page \Shopware\Storefront\Page\Product\ProductPage #}
  3.     {# @var product \Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity #}
  4.     {% set product = page.product %}
  5.     <form
  6.         id="productDetailPageBuyProductForm"
  7.         action="{% block page_product_detail_buy_form_action %}{{ path('frontend.checkout.line-item.add') }}{% endblock %}"
  8.         method="post"
  9.         class="buy-widget"
  10.         data-add-to-cart="true">
  11.         {# @deprecated tag:v6.5.0 - Block page_product_detail_buy_form_inner_csrf will be removed. #}
  12.         {% block page_product_detail_buy_form_inner_csrf %}
  13.             {{ sw_csrf('frontend.checkout.line-item.add') }}
  14.         {% endblock %}
  15.         {% set buyable = product.available and product.childCount <= 0 and product.calculatedMaxPurchase > 0 %}
  16.         {% block page_product_detail_buy_container %}
  17.             {% if buyable %}
  18.                 <div class="{{ formRowClass }} buy-widget-container">
  19.                     {% block page_product_detail_buy_quantity_container %}
  20.                         <div class="col-4">
  21.                             {% set selectQuantityThreshold = 100 %}
  22.                             {% block page_product_detail_buy_quantity %}
  23.                                 {# @deprecated tag:v6.5.0 - Numeric quantity input with additional plus/minus controls will be the default. #}
  24.                                 {% if (product.calculatedMaxPurchase - product.minPurchase) / product.purchaseSteps > selectQuantityThreshold %}
  25.                                     {% block page_product_detail_buy_quantity_input_group %}
  26.                                         <div class="input-group">
  27.                                             {% block page_product_detail_buy_quantity_input %}
  28.                                                 <input
  29.                                                     type="number"
  30.                                                     name="lineItems[{{ product.id }}][quantity]"
  31.                                                     class="form-control product-detail-quantity-input"
  32.                                                     min="{{ product.minPurchase }}"
  33.                                                     max="{{ product.calculatedMaxPurchase }}"
  34.                                                     step="{{ product.purchaseSteps }}"
  35.                                                     value="{{ product.minPurchase }}"
  36.                                                 />
  37.                                             {% endblock %}
  38.                                             {% block page_product_detail_buy_quantity_input_unit %}
  39.                                                 {% if product.translated.packUnit %}
  40.                                                     {% if not feature('v6.5.0.0') %}
  41.                                                         <div class="input-group-append">
  42.                                                     {% endif %}
  43.                                                         <span class="input-group-text">
  44.                                                             {% if product.minPurchase > 1 and product.translated.packUnitPlural %}
  45.                                                                 {{ product.translated.packUnitPlural }}
  46.                                                             {% elseif product.translated.packUnit %}
  47.                                                                 {{ product.translated.packUnit }}
  48.                                                             {% endif %}
  49.                                                         </span>
  50.                                                     {% if not feature('v6.5.0.0') %}
  51.                                                         </div>
  52.                                                     {% endif %}
  53.                                                 {% endif %}
  54.                                             {% endblock %}
  55.                                         </div>
  56.                                     {% endblock %}
  57.                                 {% else %}
  58.                                     {% block page_product_detail_buy_quantity_select %}
  59.                                         <select name="lineItems[{{ product.id }}][quantity]"
  60.                                                 class="{{ formSelectClass }} product-detail-quantity-select">
  61.                                             {% for quantity in range(product.minPurchase, product.calculatedMaxPurchase, product.purchaseSteps) %}
  62.                                                 <option value="{{ quantity }}">
  63.                                                     {{ quantity }}
  64.                                                     {% if quantity == 1 %}
  65.                                                         {% if product.translated.packUnit %} {{ product.translated.packUnit }}{% endif %}
  66.                                                     {% else %}
  67.                                                         {% if product.translated.packUnitPlural %}
  68.                                                             {{ product.translated.packUnitPlural }}
  69.                                                         {% elseif product.translated.packUnit %}
  70.                                                             {{ product.translated.packUnit }}
  71.                                                         {% endif %}
  72.                                                     {% endif %}
  73.                                                 </option>
  74.                                             {% endfor %}
  75.                                         </select>
  76.                                     {% endblock %}
  77.                                 {% endif %}
  78.                             {% endblock %}
  79.                         </div>
  80.                     {% endblock %}
  81.                     {% block page_product_detail_buy_redirect_input %}
  82.                         {# fallback redirect back to detail page is deactivated via js #}
  83.                         <input type="hidden"
  84.                                name="redirectTo"
  85.                                value="frontend.detail.page">
  86.                         <input type="hidden"
  87.                                name="redirectParameters"
  88.                                data-redirect-parameters="true"
  89.                                value='{"productId": "{{ product.id }}"}'>
  90.                     {% endblock %}
  91.                     {% block page_product_detail_buy_product_buy_info %}
  92.                         <input type="hidden"
  93.                                name="lineItems[{{ product.id }}][id]"
  94.                                value="{{ product.id }}">
  95.                         <input type="hidden"
  96.                                name="lineItems[{{ product.id }}][type]"
  97.                                value="product">
  98.                         <input type="hidden"
  99.                                name="lineItems[{{ product.id }}][referencedId]"
  100.                                value="{{ product.id }}">
  101.                         <input type="hidden"
  102.                                name="lineItems[{{ product.id }}][stackable]"
  103.                                value="1">
  104.                         <input type="hidden"
  105.                                name="lineItems[{{ product.id }}][removable]"
  106.                                value="1">
  107.                     {% endblock %}
  108.                     {% block page_product_detail_product_buy_meta %}
  109.                         <input type="hidden"
  110.                                name="product-name"
  111.                                value="{{ product.translated.name }}">
  112.                         <input type="hidden"
  113.                                name="brand-name"
  114.                                value="{{ product.manufacturer.getName() }}">
  115.                     {% endblock %}
  116.                     {% block page_product_detail_buy_button_container %}
  117.                         <div class="col-8">
  118.                             {% block page_product_detail_buy_button %}
  119.                                 {# @deprecated tag:v6.5.0 - Bootstrap v5 removes `btn-block` class, use `d-grid` wrapper instead #}
  120.                                 {% if feature('v6.5.0.0') %}
  121.                                     <div class="d-grid">
  122.                                         <button class="btn btn-primary btn-buy"
  123.                                                 title="{{ "detail.addProduct"|trans|striptags }}"
  124.                                                 aria-label="{{ "detail.addProduct"|trans|striptags }}">
  125.                                             {{ "detail.addProduct"|trans|sw_sanitize }}
  126.                                         </button>
  127.                                     </div>
  128.                                 {% else %}
  129.                                     <button class="btn btn-primary btn-block btn-buy"
  130.                                             title="{{ "detail.addProduct"|trans|striptags }}"
  131.                                             aria-label="{{ "detail.addProduct"|trans|striptags }}">
  132.                                         {{ "detail.addProduct"|trans|sw_sanitize }}
  133.                                     </button>
  134.                                 {% endif %}
  135.                             {% endblock %}
  136.                         </div>
  137.                     {% endblock %}
  138.                 </div>
  139.             {% endif %}
  140.         {% endblock %}
  141.     </form>
  142. {% endblock %}