You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

95 lines
2.9 KiB

{% extends 'base.html' %}
{% load static %}
{% block title %}
Your Cart
{% endblock %}
{% block content %}
<h1>Your Cart</h1>
<table class="table-cart" border="1px">
<thead>
<tr>
<th>Image</th>
<th>Product</th>
<th>Quantity</th>
<th>Delete</th>
<th>Price per item</th>
<th>Full price</th>
</tr>
</thead>
<tbody>
{% for item in cart %}
{% with offer=item.offer %}
<tr>
<td class="cart-img">
<a href="{{ offer.get_absolute_url }}">
<img src="{{ offer.product.image.url }}" alt="" />
</a>
</td>
<td>{{ offer.name }}</td>
<td>
<form action="{% url 'cart:CartAdd' %}" method="post" class="add">
{% csrf_token %}
{{ item.update_quantity_form.quantity }}
{{ item.update_quantity_form.update }}
<input type="submit" value="Update">
</form>
</td>
<td><a href="{% url 'cart:CartRemove' offer.slug %}">Delete</a></td>
<td class="num">{{ item.price }} rub.</td>
<td class="num">{{ item.total_price }} rub.</td>
</tr>
{% endwith %}
{% endfor %}
{% if cart.discount %}
<tr class="subtotal">
<td>Total price without discount</td>
<td colspan="4"></td>
<td>{{ cart.get_total_price }}</td>
</tr>
<tr>
<td>
"{{ cart.discount.code }}" discount for ({{ cart.discount.discount }} %)
</td>
<td colspan="4"></td>
<td class="num discount">- {{ cart.get_discount|floatformat:"2" }} руб.</td>
</tr>
{% endif %}
<tr class="total">
<td>Total</td>
<td colspan="4"></td>
<td class="num">{{ cart.get_total_price|floatformat:"2" }} руб.
{% if cart.points %}
<tr>
<td colspan="5"></td>
<td>- {{ user.profile.user_points }} бал.</td>
</tr>
<tr>
<td colspan="5"></td>
<td>{{ cart.get_total_deduct_points }} руб.</td>
</tr>
{% endif %}
</td>
</tr>
</tbody>
</table>
<!--<p>Apply Discount</p>-->
<!--<form action="{% url 'discount:apply' %}" method="post" class="add">-->
<!--{% csrf_token %}-->
<!--{{ discount_apply_form }}-->
<!--<input type="submit" value="Apply">-->
<!--</form>-->
<p>Использовать баллы: {{ user.profile.user_points }}</p>
<form action="{% url 'discount:points' %}" method="post">{% csrf_token %}
<input type="submit" name="points" value="GO" />
</form>
<p class="text-right">
<a href="{% url 'products:ProductList'%}" class="btn btn-success">Добавить товар</a>
<a href="{% url 'orders:OrderCreate' %}" class="btn btn-success">Оформить заказ</a>
</p>
{% endblock %}