{% sw_extends '@Storefront/storefront/component/buy-widget/buy-widget-form.html.twig' %}

{% block buy_widget_buy_container %}
    {% if buyable %}
        <div class="buy-widget-container">
            {% block buy_widget_buy_quantity_container %}
                {% if showQuantitySelect %}
                        {% set selectQuantityThreshold = 100 %}
                        {% block page_product_detail_buy_quantity %}
                            {% block page_product_detail_buy_quantity_input_group %}
                                <div class="input-group product-detail-quantity-group quantity-selector-group"
                                     data-quantity-selector="true">
                                    {% block page_product_detail_buy_quantity_input %}

                                        <input type="hidden" class="js-quantity-selector">
                                        <input type="hidden" class="js-btn-plus">
                                        <input type="hidden" class="js-btn-minus">

                                        <select class="form-select"
                                                name="lineItems[{{ product.id }}][quantity]">
                                            <option selected="selected"
                                                    value="{{ product.minPurchase }}">{{ product.minPurchase }}</option>
                                            {% for i in range(product.minPurchase + 1, product.minPurchase + 5) %}
                                                <option value="{{ i }}">{{ i }}</option>
                                            {% endfor %}
                                        </select>

                                    {% endblock %}
                                    {% block page_product_detail_buy_quantity_input_unit %}
                                        {% if product.translated.packUnit %}
                                            <span class="input-group-text">
                                                {% if product.minPurchase > 1 and product.translated.packUnitPlural %}
                                                    {{ product.translated.packUnitPlural }}
                                                {% elseif product.translated.packUnit %}
                                                    {{ product.translated.packUnit }}
                                                {% endif %}
                                            </span>
                                        {% endif %}
                                    {% endblock %}
                                </div>
                            {% endblock %}
                        {% endblock %}
                {% endif %}
            {% endblock %}
            {% block buy_widget_buy_redirect_input %}
                {{ parent() }}
            {% endblock %}

            {% block buy_widget_buy_product_buy_info %}
                {{ parent() }}
            {% endblock %}

            {% block buy_widget_product_buy_meta %}
                {{ parent() }}
            {% endblock %}

            {% block buy_widget_buy_button_container %}
                {% block buy_widget_buy_button %}
                    <button class="btn btn-primary btn-buy"
                            type="submit"
                            title="{{ 'detail.addProduct'|trans|striptags }}"
                            aria-label="{{ 'detail.addProduct'|trans|striptags }}">
                        <i class="fa-kit fa-cart"></i> {{ 'detail.addProduct'|trans|sw_sanitize }}
                    </button>
                {% endblock %}
            {% endblock %}
        </div>
    {% endif %}
{% endblock %}

