{% block _cart_deliveryMethod_widget %}
    <div class="grid-x grid-margin-x align-middle">
    {% if form.vars.choices %}
        <div class="cell small-12">
            <h4 class="address" {% if config.otherDeliveryMethodColor %} style="background-color: {{ config.otherDeliveryMethodColor }}" {% endif %}>{% trans %}shop.delivery_method.other_delivery{% endtrans %}
                <br><small>{% trans %} shop.address_shipping_other_description {% endtrans %}</small></h4>
        </div>
        </div>
        {% set category = '' %}
        {% set category_next = null %}
        {% set count = 1 %}
        {% set first = false %}
        {% for choice in form.vars.choices %}
            {% set counties = '' %}
            {% for county in choice.data.counties %}
                {% if loop.last == false %}
                    {% set counties = counties ~ county.code ~ '-' %}
                {% else %}
                    {% set counties = counties ~ county.code %}
                {% endif %}
            {% endfor %}
            {% if category != choice.data.category.name %}
                {% set first = true %}
                <div class="category-group">
                <div class="grid-x grid-margin-x align-middle category-group-content {% if choice.data.category.minView %}hide-list-method{% endif %}">
            {% else %}
                {% set first = false %}
                {% set count = count + 1 %}
            {% endif %}
            <div class="cell small-12 {% if first %}first-method{% endif %}">
                {% if category != choice.data.category.name %}
                    {% set count = 1 %}
                    <h4 class="shop">{{ choice.data.category.name }}</h4>
                    {% if choice.data.category.description %}
                        <div class="deliveryMethod_description deliveryMethod_category_description">{{ choice.data.category.description|raw }}</div>
                    {% endif %}
                {% endif %}
                {%- if required -%}
                    {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%}
                {%- endif -%}
                {%- if parent_label_class is defined -%}
                    {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) -%}
                {%- endif -%}
                {%- if label is not same as(false) and label is empty -%}
                    {%- if label_format is not empty -%}
                        {%- set label = label_format|replace({
                            '%name%': name,
                            '%id%': id,
                        }) -%}
                    {%- else -%}
                        {% set label = name|humanize %}
                    {%- endif -%}
                {%- endif -%}
                {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' control-label')|trim}) -%}
                {%- set label_attr = label_attr|merge({'for': id}) -%}
                <label class="cart_deliveryMethod" for="cart_deliveryMethod_{{ loop.index }}-1">
                    <input class="input_cart_deliveryMethod" type="checkbox"
                           id="cart_deliveryMethod_{{ loop.index }}-1" name="{{ full_name }}"
                            {%- if disabled %} disabled="disabled"{% endif -%}
                            {%- if required %} required="required"{% endif -%} {% if choice.value is defined %} value="{{ choice.value }}"{% endif %}{% if form.vars.data is defined %} {% if form.vars.data == choice.data %}checked="checked"{% endif %} {% endif %}
                           data-qtyAt="{{ choice.data.qtyAt }}"
                           data-packepagePrice="{{ choice.data.packagePrice }}"
                           data-bottlePrice="{{ choice.data.bottlePrice }}" data-counties="{{ counties }}"
                           data-viewCounties="{{ choice.data.viewCounties }}"
                    />
                    <span class="label_cart_deliveryMethod">{{ choice.label }}</span>
                    {% if choice.data.description %}<span class="deliveryMethod_description">{{ choice.data.description|raw }}</span>{% endif %}
                    {% if choice.data.viewCounties %}
                        <div class="label_deliveryMethod_counties">
                            {% trans with {'%count%': choice.data.counties|length , '%counties%' : counties} %}shop.delivery_method.In_the_county{% endtrans %}
                        </div>
                    {% endif %}
                    {% if choice.data.qtyAt %}
                        <div class="label_deliveryMethod_qty">
                            <i class="fas fa-exclamation-triangle"></i> {{ "shop.delivery_method.Qty_minimum_required" |trans() }}
                            : {{ choice.data.qtyAt }} {{ "shop.delivery_method.bottles" |trans() }}
                        </div>
                    {% endif %}
                    {% if choice.data.enabledShippingPrice == false %}
                        <div class="label_deliveryMethod_price">
                            {% if choice.data.packagePrice is not null %}
                                {% if choice.data.packagePrice == 0 %}
                                    <u>{{ "shop.delivery_method.Free_shipping" | trans() }}</u>
                                {% else %}
                                    <u>{{ "shop.delivery_method.Shipping" | trans() }}
                                        : {{ "shop.delivery_method.Package_of" | trans() }} {{ choice.data.packagePrice/100 }}
                                        €</u>
                                {% endif %}
                            {% else %}
                                <u>{{ "shop.delivery_method.Shipping" | trans() }} : {{ choice.data.bottlePrice/100 }}
                                    € {{ "shop.delivery_method.per_bottle" | trans() }}</u>
                            {% endif %}

                        </div>
                    {% endif %}
                     {% if choice.data.otherText is not null %}
                            <div class="label_deliveryMethod_otherInfo">
                                <span class="deliveryMethod_description">{{ choice.data.otherText | raw }}</span>
                            </div>
                        {% endif %}
                    {% if choice.data.productVariants is defined %}
                        {% if choice.data.viewProduct %}
                            {% if choice.data.productVariants|length > 0 %}
                                <i class="fas fa-info-circle"></i> <a class="product-delivery" href="#"
                                                                      title="{{ "shop.delivery_method.viewProduct" | trans() }} - {{ choice.label }}"
                                                                      data-label="{{ choice.label }}"
                                                                      data-delivery="{{ choice.data.id }}"
                                                                      data-scroll-ignore>{% if choice.data.depot %}{{ "shop.delivery_method.viewProductDepot" | trans() }}{% else %}{{ "shop.delivery_method.viewProduct" | trans() }}{% endif %}
                                ({{ choice.data.productVariants|length }})</a>
                            {% else %}
                                <i class="fas fa-info-circle"></i>
                                <span>{% if choice.data.depot %}{{ "shop.delivery_method.viewProductDepotAll" | trans() }}{% else %}{{ "shop.delivery_method.viewProductAll" | trans() }}{% endif %}</span>
                            {% endif %}
                        {% endif %}
                    {% endif %}
                </label>
            </div>
            {% set category = choice.data.category.name %}
            {% if choices[loop.index] is defined %}
                {% set category_next = choices[loop.index].data.category.name %}
            {% else %}
                </div>
                {% if choice.data.category.minView %}
                    <div class="show-more-list">
                        <a href="#" {% if config.otherDeliveryMethodColor %} style="background-color: {{ config.otherDeliveryMethodColor }}"{% endif %} title="{{ choice.data.category.minViewTextOpen }}"
                           data-scroll-ignore data-text-open="{{ choice.data.category.minViewTextOpen }}"
                           data-text-close="{{ choice.data.category.minViewTextClose }}"><span>{{ choice.data.category.minViewTextOpen }}</span>
                            ({{ count }})</a>
                    </div>
                {% endif %}
                </div>
            {% endif %}
            {% if category_next is not null %}
                {% if category_next != category %}
                    </div>
                    {% if choice.data.category.minView %}
                        <div class="show-more-list">
                            <a href="#" {% if config.otherDeliveryMethodColor %} style="background-color: {{ config.otherDeliveryMethodColor }}"{% endif %} title="{{ choice.data.category.minViewTextOpen }}"
                               data-scroll-ignore data-text-open="{{ choice.data.category.minViewTextOpen }}"
                               data-text-close="{{ choice.data.category.minViewTextClose }}"><span>{{ choice.data.category.minViewTextOpen }}</span>
                                ({{ count }})</a>
                        </div>
                    {% endif %}
                    </div>
                {% endif %}
            {% endif %}
        {% endfor %}
    {% endif %}
{% endblock %}

{% block _cart_promo_widget %}
    <div class="form_cart_promo">
        <label for="cart_promo"></label>
        <input type="text" id="cart_promo" name="cart[promo]" class="promo form-control">
        <div class="verif-promo"></div>
    </div>
{% endblock %}
{% block _cart_invoiceAddress_postalCode_widget %}
    {{ block('form_widget_simple') }}
    <div id="output_postal_invoice" class="output_postal"></div>
{% endblock %}
{% block _cart_deliveryAddress_postalCode_widget %}
    {{ block('form_widget_simple') }}
    <div id="output_postal_delivery" class="output_postal"></div>
{% endblock %}

{% block cart_item_widget %}
    <div class="grid-x grid-margin-x align-middle">
        <div class="cell small-5">
            {{ form_widget(form.variant) }}
            <span id="cart_items_{{ form.vars.name }}_name">
                {% if form.vars.data %}
                    {% set quality = '' %}
                    {% if form.vars.data.variant.product.quality %}
                        {% set quality = form.vars.data.variant.product.quality %}
                    {% endif %}
                    {% if form.vars.data.variant.product.name == form.vars.data.variant.type.name %}
                        {% set name = form.vars.data.variant.product.name~" "~quality %}
                    {% else %}
                        {% set name = form.vars.data.variant.product.name~" "~quality~" - "~form.vars.data.variant.type.name %}
                    {% endif %}
                    {{ name ~ " "~form.vars.data.variant.type.volume ~ " "~form.vars.data.variant.type.unity }}
                {% endif %}
            </span>
        </div>
        <div class="cell small-2">
            {% if form.vars.data %}
                {{ form_widget(form.quantity, { 'attr': {'data-item': form.vars.data.variant.id} }) }}
            {% else %}
                {{ form_widget(form.quantity) }}
            {% endif %}
        </div>
        {% if form.vars.data %}
            {% if form.vars.data.variant.priceDiscount %}
                {% set price = (form.vars.data.variant.priceDiscount/100) | number_format(2) %}
            {% else %}
                {% set price = (form.vars.data.variant.price/100) | number_format(2) %}
            {% endif %}
            <span id="cart_items_{{ form.vars.name }}_price" data-item="{{ form.vars.data.variant.id }}"
                  data-price="{{ price }}"
                  class="cell small-2 cart-item-price">

                {{ price }} €
            </span>
        {% else %}
            <span id="cart_items_{{ form.vars.name }}_price" class="cell small-2 cart-item-price"></span>
        {% endif %}
        {% if form.vars.data %}
            <span id="cart_items_{{ form.vars.name }}_total" data-item="{{ form.vars.data.variant.id }}"
                  class="cell small-2 cart-item-total">
                {% set quantity = form.vars.data.quantity %}
                {{ (price*quantity)|number_format(2,'.','') }} €
            </span>
        {% else %}
            <span id="cart_items_{{ form.vars.name }}_total" class="cell small-2 cart-item-total"></span>
        {% endif %}
        <a class="cell small-1 delete-cart-row" data-scroll-ignore>
            <i class="fas fa-trash-alt "></i>
        </a>
    </div>
{% endblock %}


{% block cgv_widget %}
    {%- set label_attr = label_attr|merge({'for': id}) -%}
    {%- if required -%}
        {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%}
    {%- endif -%}
    {%- if parent_label_class is defined -%}
        {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) -%}
    {%- endif -%}
    {%- if label is not same as(false) and label is empty -%}
        {%- if label_format is not empty -%}
            {%- set label = label_format|replace({
                '%name%': name,
                '%id%': id,
            }) -%}
        {%- else -%}
            {% set label = name|humanize %}
        {%- endif -%}
    {%- endif -%}
    <div class="checkbox">
        <label {% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
            <input type="checkbox" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %}
                   required="required"/>
            <a href="{{ path('cgv') }}" target="_blank">{% trans %}shop.accept_cgv{% endtrans %}</a>
        </label>
    </div>
{% endblock %}
