{% extends "base.html" %}

{% load i18n plata_tags %}

{% block title %}{% trans "Cart" %} - {{ block.super }}{% endblock %}

{% block content %}
{% if empty %}
<h1>{% trans "Cart is empty!" %}</h1>
{% else %}
<h1>{% trans "Cart" %}</h1>

<form method="post" action=".">{% csrf_token %}{{ orderitemformset.management_form }}

{% form_errors orderitemformset %}
<table>
    <tr>
        <th>{% trans "product"|capfirst %}</th>
        <th>{% trans "unit price"|capfirst %}</th>
        <th>{% trans "quantity"|capfirst %}</th>
        <th>{% trans "line item price"|capfirst %}</th>
        <th>{% trans "Delete" %}</th>
    </tr>
{% for orderitemform in orderitemformset.forms %}
    <tr>
        <td>{{ orderitemform.instance.variation }}</td>
        <td>{{ orderitemform.instance.unit_price|floatformat:2 }}</td>
        <td>
            {{ orderitemform.id }}
            {% form_item_plain orderitemform.quantity %}
        </td>
        <td>{{ orderitemform.instance.discounted_subtotal|floatformat:2 }}</td>
        <td>{% form_item_plain orderitemform.DELETE %}</td>
    </tr>
{% endfor %}
    <tr>
        <td colspan="2"></td>
        <td colspan="3">
            <input type="submit" name="save" value="{% trans "Save" %}" />
            <input type="submit" name="checkout" value="{% trans "Checkout" %}" />
        </td>
    </tr>
</table>
</form>
{% endif %}
{% endblock %}
