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