{% extends "shop/base.html" %}
{% load i18n %}
{% load static %} 

{% block title %}{% trans "Zapłać za zamówienie" %}{% endblock %}

{% block content %}
  <h1>{% trans "Podsumowanie zamówienia" %}</h1>
  <table class="cart">
    <thead>
      <tr>
        <th>{% trans "Zdjęcie" %}</th>
        <th>{% trans "Produkt" %}</th>
        <th>{% trans "Cena" %}</th>
        <th>{% trans "Ilość" %}</th>
        <th>{% trans "Razem" %}</th>
      </tr>
    </thead>
    <tbody>
      {% for item in order.items.all %}
        <tr class="row{% cycle "1" "2" %}">
          <td>
            <img src="{% if item.product.image %}{{ item.product.image.url }}
            {% else %}{% static "img/no_image.png" %}{% endif %}">
          </td>
          <td>{{ item.product.name }}</td>
          <td class="num">{{ item.price }} zł</td>
          <td class="num">{{ item.quantity }}</td>
          <td class="num">{{ item.get_cost }} zł</td>
        </tr>
      {% endfor %}
      {% if order.coupon %}
  <tr class="subtotal">
    <td>{% trans "Suma częściowa" %}</td>
    <td colspan="3"></td>
    <td class="num">
      {{ order.get_total_cost_before_discount|floatformat:2 }} zł
    </td>
  </tr>
  <tr>
    <td>
      {% blocktrans with code=order.coupon.code discount=order.discount %}
        "{{ code }}" ({{ discount }}%  rabatu)
      {% endblocktrans %}
    </td>
    <td colspan="3"></td>
    <td class="num neg">
      - {{ order.get_discount|floatformat:2 }} zł
    </td>
  </tr>
{% endif %}
<tr class="total">
  <td>{% trans "Razem" %}</td>
  <td colspan="3"></td>
  <td class="num">
    {{ order.get_total_cost|floatformat:2 }} zł
  </td>
</tr>

    </tbody>
  </table>
  <form action="{% url "payment:process" %}" method="post">
    <input type="submit" value="{% trans "Zapłać teraz" %}">
    {% csrf_token %}
  </form>
{% endblock %}
