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