{% extends 'shop/base.html' %}
{% load static %}

{% block title %} 
    Checkout
{% endblock title %}

{% block content %}
<div class="container">
    <div class="row">
        <div class="col-md-6">
            <h3>Items in Cart</h3>
            <a href="{% url 'mycart' %}">UPDATE CART</a>
            <table class="table">
                <thead>
                    <tr>
                        <th>SN</th>
                        <th>Product</th>
                        <th>Rate</th>
                        <th>Quantity</th>
                        <th>Subtotal</th>
                    </tr>
                </thead>
                <tbody>
                    {% for cp in cart.cartproduct_set.all %}
                    <tr>
                        <td>{{forloop.counter}}</td>
                        <td>{{cp.product.title}}</td>
                        <td>{{cp.rate}}</td>
                        <td>{{cp.quantity}}</td>
                        <td>{{cp.subtotal}}</td>
                    </tr>
                    {%endfor%}
                    <tr>
                        <th colspan="4" class="text-right">Total</th>
                        <th>Rs. {{ cart.total }}</th>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="col-md-6">
            <h3>Checkout Form</h3>
            <form action="" method="POST">
                {% csrf_token %}
                {{form.as_p}}
                <button class="btn btn-info"> Place Order</button>
            </form>
        </div>
    </div>
</div>
{% endblock content %}