vendor/shopware/storefront/Resources/views/storefront/component/buy-widget/buy-widget-form.html.twig line 1

Open in your IDE?
  1. {% block buy_widget_buy_form_inner %}
  2.     <form
  3.         id="productDetailPageBuyProductForm"
  4.         action="{% block buy_widget_buy_form_action %}{{ path('frontend.checkout.line-item.add') }}{% endblock %}"
  5.         method="post"
  6.         class="buy-widget"
  7.         data-add-to-cart="true">
  8.         {# @deprecated tag:v6.5.0 - Block buy_widget_buy_form_inner_csrf will be removed. #}
  9.         {% block buy_widget_buy_form_inner_csrf %}
  10.             {{ sw_csrf('frontend.checkout.line-item.add') }}
  11.         {% endblock %}
  12.         {% set DOWNLOAD_STATE = constant('Shopware\\Core\\Content\\Product\\State::IS_DOWNLOAD') %}
  13.         {% set showQuantitySelect = not product.states is defined or DOWNLOAD_STATE not in product.states or (DOWNLOAD_STATE in product.states and product.maxPurchase !== 1) %}
  14.         {% set buyable = product.available and product.childCount <= 0 and product.calculatedMaxPurchase > 0 %}
  15.         {% block buy_widget_buy_container %}
  16.             {% if buyable %}
  17.                 <div class="{{ formRowClass }} buy-widget-container">
  18.                     {% block buy_widget_buy_quantity_container %}
  19.                         {% if showQuantitySelect %}
  20.                             <div class="col-4">
  21.                                 {% set selectQuantityThreshold = 100 %}
  22.                                 {% block buy_widget_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 buy_widget_buy_quantity_input_group %}
  26.                                             <div class="input-group">
  27.                                                 {% block buy_widget_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 buy_widget_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 buy_widget_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.                         {% endif %}
  81.                     {% endblock %}
  82.                     {% block buy_widget_buy_redirect_input %}
  83.                         {# fallback redirect back to detail page is deactivated via js #}
  84.                         <input type="hidden"
  85.                                name="redirectTo"
  86.                                value="frontend.detail.page">
  87.                         <input type="hidden"
  88.                                name="redirectParameters"
  89.                                data-redirect-parameters="true"
  90.                                value='{"productId": "{{ product.id }}"}'>
  91.                     {% endblock %}
  92.                     {% block buy_widget_buy_product_buy_info %}
  93.                         <input type="hidden"
  94.                                name="lineItems[{{ product.id }}][id]"
  95.                                value="{{ product.id }}">
  96.                         <input type="hidden"
  97.                                name="lineItems[{{ product.id }}][type]"
  98.                                value="product">
  99.                         <input type="hidden"
  100.                                name="lineItems[{{ product.id }}][referencedId]"
  101.                                value="{{ product.id }}">
  102.                         <input type="hidden"
  103.                                name="lineItems[{{ product.id }}][stackable]"
  104.                                value="1">
  105.                         <input type="hidden"
  106.                                name="lineItems[{{ product.id }}][removable]"
  107.                                value="1">
  108.                     {% endblock %}
  109.                     {% block buy_widget_product_buy_meta %}
  110.                         <input type="hidden"
  111.                                name="product-name"
  112.                                value="{{ product.translated.name }}">
  113.                         <input type="hidden"
  114.                                name="brand-name"
  115.                                value="{{ product.manufacturer.getName() }}">
  116.                     {% endblock %}
  117.                     {% block buy_widget_buy_button_container %}
  118.                         <div class="{% if showQuantitySelect %}col-8{% else %}col-12{% endif %}">
  119.                             {% block buy_widget_buy_button %}
  120.                                 {# @deprecated tag:v6.5.0 - Bootstrap v5 removes `btn-block` class, use `d-grid` wrapper instead #}
  121.                                 {% if feature('v6.5.0.0') %}
  122.                                     <div class="d-grid">
  123.                                         <button class="btn btn-primary btn-buy"
  124.                                                 title="{{ "detail.addProduct"|trans|striptags }}"
  125.                                                 aria-label="{{ "detail.addProduct"|trans|striptags }}">
  126.                                             {{ "detail.addProduct"|trans|sw_sanitize }}
  127.                                         </button>
  128.                                     </div>
  129.                                 {% else %}
  130.                                     <button class="btn btn-primary btn-block btn-buy"
  131.                                             title="{{ "detail.addProduct"|trans|striptags }}"
  132.                                             aria-label="{{ "detail.addProduct"|trans|striptags }}">
  133.                                         {{ "detail.addProduct"|trans|sw_sanitize }}
  134.                                     </button>
  135.                                 {% endif %}
  136.                             {% endblock %}
  137.                         </div>
  138.                     {% endblock %}
  139.                 </div>
  140.             {% endif %}
  141.         {% endblock %}
  142.     </form>
  143. {% endblock %}