{% load i18n lfs_tags %}

{# Voucher #}
<h2 class="padding-top-large">
    {% trans "Voucher code" %}
</h2>
<input data="{% url lfs_check_voucher %}"
       type="text"
       id="voucher"
       name="voucher"
       value="{{ voucher_number }}"
       size="30" />

{% if voucher_number and voucher_message %}
    <span class="voucher-message">
        {{ voucher_message }}
    </span>
{% endif %}

<h2>{% trans 'Your cart' %}</h2>
<table class="lfs-default cart">
    <tr>
        <th colspan="2">
            {% trans 'Product' %}
        </th>
        <th class="number">
            {% trans 'Amount' %}
        </th>
        <th class="number">
            {% trans 'Price' %}
        </th>
        <th class="number">
            {% trans 'Included VAT' %}
        </th>
        <th class="number">
            {% trans 'Total' %}
        </th>
    </tr>
    {% for cart_item in cart.items %}
        <tr>
            <td class="image">
                <a href="{{ cart_item.product.get_absolute_url }}">
                    <img src="{{ cart_item.product.get_image.url_60x60 }}"
                         alt="{{ cart_item.product.get_name }}"/>
                </a>
            </td>
            <td>
                {{ cart_item.product.get_name }}
                {% for property in cart_item.product.get_variant_properties %}
                    <div>
                        {{ property.title }}: {{ property.value }} {{ property.unit|safe }}
                    </div>
                {% endfor %}

                {% for property in cart_item.product.get_displayed_properties %}
                    <div>
                        {{ property.title }}: {{ property.value }} {{ property.unit|safe }}
                    </div>
                {% endfor %}

                {% if cart_item.product.is_configurable_product %}
                    {% for property in cart_item.get_properties %}
                        <div>
                            {{ property.title }}: {{ property.value }} {{ property.unit|safe }}
                            {% if property.display_price %}
                                ({{ property.price|currency }})
                            {% endif %}                            
                        </div>
                    {% endfor %}
                {% endif %}

            </td>
            <td class="number">
                {{ cart_item.amount }} {{ cart_item.product.unit }}
                
                {% if cart_item.product.active_packing_unit %}
                    <span class="packing-unit">
                        ({{ cart_item|packages }} {{ cart_item.product.packing_unit_unit }})
                    </span>
                {% endif %}
                
            </td>
            <td class="number">
                {{ cart_item.product.get_price|currency }}
                {% if cart_item.product.price_unit %}
                    / {{ cart_item.product.price_unit }}
                {% endif %}

            </td>
            <td class="number">
                ({{ cart_item.get_tax|currency }})
            </td>
            <td class="number">
                {{ cart_item.get_price|currency }}
            </td>
        </tr>
    {% endfor %}

    {% for discount in discounts %}
        <tr id="discounts-display">
            <td></td>
            <td class="left">
                {{ discount.name }}
            </td>
            <td class="number">
                1
            </td>
            <td class="number">
                - {{ discount.price|currency }}
            </td>
            <td class="number">
                {% if discount.tax %}
                    (- {{ discount.tax|currency }})
                {% endif %}
            </td>
            <td class="number">
                - {{ discount.price|currency }}
            </td>
            <td></td>
        </tr>
    {% endfor %}

    {% if display_voucher %}
        <tr id="voucher-display">
            <td></td>
            <td class="left">
                {% trans "Voucher" %}
            </td>
            <td class="number">
                1
            </td>
            <td class="number">
                - {{ voucher_value|currency }}
            </td>
            <td class="number">
                ({{ voucher_tax|currency }})
            </td>
            <td class="number">
                - {{ voucher_value|currency }}
            </td>
        </tr>
    {% endif %}

    <tr>
        <td></td>
        <td>
            {% trans 'Shipping' %} ({{ selected_shipping_method.name }})
        </td>
        <td class="number">
            1
        </td>
        <td class="number">
            {{ shipping_price|currency }}
        </td>
        <td></td>
        <td class="number">
            {{ shipping_price|currency }}
        </td>
    </tr>

    <tr>
        <td></td>
        <td>
            {% trans 'Payment' %} ({{ selected_payment_method.name }})
        </td>
        <td class="number">
            1
        </td>
        <td class="number">
            {{ payment_price|currency }}
        </td>
        <td></td>
        <td class="number">
            {{ payment_price|currency }}
        </td>
    </tr>

    <tr>
        <td colspan="6"
            class="total number padding-top">
            <span class="total-label">{% trans 'Total' %}:</span>
            {{ cart_price|currency }}
        </td>
    </tr>
    <tr>
        <td colspan="6"
            class="discreet number">
            <span class="total-label">{% trans 'Inclusive VAT' %}:</span>
            {{ cart_tax|currency }}
        </td>
    </tr>
</table>
