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

  1. {% set formAction = path('frontend.checkout.line-item.add') %}
  2. {% block page_product_detail_buy_form_inner %}
  3.     {# @var page \Shopware\Storefront\Page\Product\ProductPage #}
  4.     {# @var product \Shopware\Core\Content\Product\SalesChannel\SalesChannelProductEntity #}
  5.     {% set product = page.product %}
  6.     <form
  7.         id="productDetailPageBuyProductForm"
  8.         action="{% block page_product_detail_buy_form_action %}{# @deprecated tag:v6.6.0 - block will be removed, overwrite `formAction` instead #}{{ formAction }}{% endblock %}"
  9.         method="post"
  10.         class="buy-widget"
  11.         data-add-to-cart="true">
  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 page_product_detail_buy_container %}
  16.             {% if buyable %}
  17.                 <div class="row g-2 buy-widget-container">
  18.                     {% block page_product_detail_buy_quantity_container %}
  19.                         {% if showQuantitySelect %}
  20.                             <div class="col-4 d-flex justify-content-end">
  21.                                 {% set selectQuantityThreshold = 100 %}
  22.                                 {% block page_product_detail_buy_quantity %}
  23.                                     {% block page_product_detail_buy_quantity_input_group %}
  24.                                         <div class="input-group product-detail-quantity-group quantity-selector-group" data-quantity-selector="true">
  25.                                             {% block page_product_detail_buy_quantity_input %}
  26.                                                 <button type="button" class="btn btn-outline-light btn-minus js-btn-minus">
  27.                                                     {% sw_icon 'minus' style {'size': 'xs'} %}
  28.                                                 </button>
  29.                                                 <input
  30.                                                     type="number"
  31.                                                     name="lineItems[{{ product.id }}][quantity]"
  32.                                                     class="form-control js-quantity-selector quantity-selector-group-input product-detail-quantity-input"
  33.                                                     min="{{ product.minPurchase }}"
  34.                                                     max="{{ product.calculatedMaxPurchase }}"
  35.                                                     step="{{ product.purchaseSteps }}"
  36.                                                     value="{{ product.minPurchase }}"
  37.                                                 />
  38.                                                 <button type="button" class="btn btn-outline-light btn-plus js-btn-plus">
  39.                                                     {% sw_icon 'plus' style {'size': 'xs'}  %}
  40.                                                 </button>
  41.                                             {% endblock %}
  42.                                             {% block page_product_detail_buy_quantity_input_unit %}
  43.                                                 {% if product.translated.packUnit %}
  44.                                                     <span class="input-group-text">
  45.                                                         {% if product.minPurchase > 1 and product.translated.packUnitPlural %}
  46.                                                             {{ product.translated.packUnitPlural }}
  47.                                                         {% elseif product.translated.packUnit %}
  48.                                                             {{ product.translated.packUnit }}
  49.                                                         {% endif %}
  50.                                                     </span>
  51.                                                 {% endif %}
  52.                                             {% endblock %}
  53.                                         </div>
  54.                                     {% endblock %}
  55.                                 {% endblock %}
  56.                             </div>
  57.                         {% endif %}
  58.                     {% endblock %}
  59.                     {% block page_product_detail_buy_redirect_input %}
  60.                         {# fallback redirect back to detail page is deactivated via js #}
  61.                         <input type="hidden"
  62.                                name="redirectTo"
  63.                                value="frontend.detail.page">
  64.                         <input type="hidden"
  65.                                name="redirectParameters"
  66.                                data-redirect-parameters="true"
  67.                                value='{"productId": "{{ product.id }}"}'>
  68.                     {% endblock %}
  69.                     {% block page_product_detail_buy_product_buy_info %}
  70.                         <input type="hidden"
  71.                                name="lineItems[{{ product.id }}][id]"
  72.                                value="{{ product.id }}">
  73.                         <input type="hidden"
  74.                                name="lineItems[{{ product.id }}][type]"
  75.                                value="product">
  76.                         <input type="hidden"
  77.                                name="lineItems[{{ product.id }}][referencedId]"
  78.                                value="{{ product.id }}">
  79.                         <input type="hidden"
  80.                                name="lineItems[{{ product.id }}][stackable]"
  81.                                value="1">
  82.                         <input type="hidden"
  83.                                name="lineItems[{{ product.id }}][removable]"
  84.                                value="1">
  85.                     {% endblock %}
  86.                     {% block page_product_detail_product_buy_meta %}
  87.                         <input type="hidden"
  88.                                name="product-name"
  89.                                value="{{ product.translated.name }}">
  90.                         <input type="hidden"
  91.                                name="brand-name"
  92.                                value="{{ product.manufacturer.getName() }}">
  93.                     {% endblock %}
  94.                     {% block page_product_detail_buy_button_container %}
  95.                         <div class="{% if showQuantitySelect %}col-8{% else %}col-12{% endif %}">
  96.                             {% block page_product_detail_buy_button %}
  97.                                 <div class="d-grid">
  98.                                     <button class="btn btn-primary btn-buy"
  99.                                             title="{{ "detail.addProduct"|trans|striptags }}"
  100.                                             aria-label="{{ "detail.addProduct"|trans|striptags }}">
  101.                                         {{ "detail.addProduct"|trans|sw_sanitize }}
  102.                                     </button>
  103.                                 </div>
  104.                             {% endblock %}
  105.                         </div>
  106.                     {% endblock %}
  107.                 </div>
  108.             {% endif %}
  109.         {% endblock %}
  110.     </form>
  111. {% endblock %}