{% load i18n %}

<h1>{% trans "Your shopping cart" %}</h1>
{% if cart_items %}

    <form method="post" action="{% url cart_update %}">
      {% csrf_token %}
      <table border="1">
        <thead>
          <tr>
          <th>{% trans "Product name" %}</th>
          <th>{% trans "Unit price" %}</th>
          <th>{% trans "Quantity" %}</th>
          <th>&nbsp;</th>
          </tr>
        </thead>

        <tbody>
          {% for item in cart_items %}
            <tr>
              <td>{{item.product.name}}</td>    
              <td>{{item.product.get_price}}</td>
              <td><input type="text" name="update_item-{{ item.id }}"
                value="{{item.quantity}}"></td>
              <td>{{item.line_subtotal}}</td>
            </tr>
            {% for extra_price_field in item.extra_price_fields %}
              <tr>
                <td colspan="2">&nbsp;</td>
                <td>{{ extra_price_field.0 }}</td>
                <td>{{ extra_price_field.1 }}</td>
              </tr>
            {% endfor %}
            <tr><td colspan="2">&nbsp;</td><td>{% trans "Line Total" %}:</td><td>{{item.line_total}}</td></tr>
          {% endfor %}
        </tbody>

        <tfoot>
          <tr><td colspan="2">&nbsp;</td><td>{% trans "Cart Subtotal" %}</td><td>{{cart.subtotal_price}}</td></tr>
          {% for extra_price_field in cart.extra_price_fields %}
            <tr>
              <td colspan="2">&nbsp;</td>
              <td>{{ extra_price_field.0 }}</td>
              <td>{{ extra_price_field.1 }}</td>
            </tr>
          {% endfor %}
          <tr><td colspan="2">&nbsp;</td><td><b>{% trans "Cart Total" %}</b></td><td><b>{{cart.total_price}}</b></td></tr>
        </tfoot>
      </table>

      <p><input type="submit" value="{% trans "Update Shopping Cart" %}"/></p>
    </form>

    <form action="{% url cart_delete %}" method="post">
      {% csrf_token %}
      <p><input type="submit" value="{% trans "Empty Shopping Cart" %}"/></p>
    </form>

    <p>
      <a href="{% url checkout_shipping %}">{% trans "Proceed to checkout" %}</a>
    </p>

{% else %}
<p>
  {% trans "Shopping cart is empty" %}
</p>
{% endif %}
