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

  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.         {% set DOWNLOAD_STATE = constant('Shopware\\Core\\Content\\Product\\State::IS_DOWNLOAD') %}
  12.         {% set showQuantitySelect = not product.states is defined or DOWNLOAD_STATE not in product.states or (DOWNLOAD_STATE in product.states and product.maxPurchase !== 1) %}
  13.         {% set buyable = product.available and product.childCount <= 0 and product.calculatedMaxPurchase > 0 %}
  14.         {% block page_product_detail_buy_container %}
  15.             {% if buyable %}
  16.                 <div class="row g-2 buy-widget-container">
  17.                     {% block page_product_detail_buy_quantity_container %}
  18.                         {% if showQuantitySelect %}
  19.                             <div class="col-4 d-flex justify-content-end">
  20.                                 {% set selectQuantityThreshold = 100 %}
  21.                                 {% block page_product_detail_buy_quantity %}
  22.                                     {% block page_product_detail_buy_quantity_input_group %}
  23.                                         <div class="input-group product-detail-quantity-group quantity-selector-group" data-quantity-selector="true">
  24.                                             {% block page_product_detail_buy_quantity_input %}
  25.                                                 <button type="button" class="btn btn-outline-light btn-minus js-btn-minus">
  26.                                                     {% sw_icon 'minus' style {'size': 'xs'} %}
  27.                                                 </button>
  28.                                                 <input
  29.                                                     type="number"
  30.                                                     name="lineItems[{{ product.id }}][quantity]"
  31.                                                     class="form-control js-quantity-selector quantity-selector-group-input product-detail-quantity-input"
  32.                                                     min="{{ product.minPurchase }}"
  33.                                                     max="{{ product.calculatedMaxPurchase }}"
  34.                                                     step="{{ product.purchaseSteps }}"
  35.                                                     value="{{ product.minPurchase }}"
  36.                                                 />
  37.                                                 <button type="button" class="btn btn-outline-light btn-plus js-btn-plus">
  38.                                                     {% sw_icon 'plus' style {'size': 'xs'}  %}
  39.                                                 </button>
  40.                                             {% endblock %}
  41.                                             {% block page_product_detail_buy_quantity_input_unit %}
  42.                                                 {% if product.translated.packUnit %}
  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.                                                 {% endif %}
  51.                                             {% endblock %}
  52.                                         </div>
  53.                                     {% endblock %}
  54.                                 {% endblock %}
  55.                             </div>
  56.                         {% endif %}
  57.                     {% endblock %}
  58.                     {% block page_product_detail_buy_redirect_input %}
  59.                         {# fallback redirect back to detail page is deactivated via js #}
  60.                         <input type="hidden"
  61.                                name="redirectTo"
  62.                                value="frontend.detail.page">
  63.                         <input type="hidden"
  64.                                name="redirectParameters"
  65.                                data-redirect-parameters="true"
  66.                                value='{"productId": "{{ product.id }}"}'>
  67.                     {% endblock %}
  68.                     {% block page_product_detail_buy_product_buy_info %}
  69.                         <input type="hidden"
  70.                                name="lineItems[{{ product.id }}][id]"
  71.                                value="{{ product.id }}">
  72.                         <input type="hidden"
  73.                                name="lineItems[{{ product.id }}][type]"
  74.                                value="product">
  75.                         <input type="hidden"
  76.                                name="lineItems[{{ product.id }}][referencedId]"
  77.                                value="{{ product.id }}">
  78.                         <input type="hidden"
  79.                                name="lineItems[{{ product.id }}][stackable]"
  80.                                value="1">
  81.                         <input type="hidden"
  82.                                name="lineItems[{{ product.id }}][removable]"
  83.                                value="1">
  84.                     {% endblock %}
  85.                     {% block page_product_detail_product_buy_meta %}
  86.                         <input type="hidden"
  87.                                name="product-name"
  88.                                value="{{ product.translated.name }}">
  89.                         <input type="hidden"
  90.                                name="brand-name"
  91.                                value="{{ product.manufacturer.getName() }}">
  92.                     {% endblock %}
  93.                     {% block page_product_detail_buy_button_container %}
  94.                         <div class="{% if showQuantitySelect %}col-8{% else %}col-12{% endif %}">
  95.                             {% block page_product_detail_buy_button %}
  96.                                 <div class="d-grid">
  97.                                     <button class="btn btn-primary btn-buy"
  98.                                             title="{{ "detail.addProduct"|trans|striptags }}"
  99.                                             aria-label="{{ "detail.addProduct"|trans|striptags }}">
  100.                                         {{ "detail.addProduct"|trans|sw_sanitize }}
  101.                                     </button>
  102.                                 </div>
  103.                             {% endblock %}
  104.                         </div>
  105.                     {% endblock %}
  106.                 </div>
  107.             {% endif %}
  108.         {% endblock %}
  109.     </form>
  110. {% endblock %}