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.
 
 
 
 

100 lines
3.3 KiB

{% extends 'base.html' %}
{% load static %}
{% block title %}
Your Cart
{% endblock %}
{% block content %}
<h1>Ваша корзина</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="{% if offer.product.image %}{{ offer.product.image.url }}{% else %}{% static 'img/no-image.jpg'%}{% endif %}">
</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.product_slug }}
{{ item.update_quantity_form.price_per_itom }}
{{ item.update_quantity_form.update }}
<input type="submit" value="Изменить">
</form>
</td>
<td><a href="{% url 'cart:CartRemove' offer.slug %}">Удалить</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 colspan="5">Всего</td>
<td class="num">{{ cart.get_total_price|floatformat:"2" }} руб.
{% if request.session.points %}
<tr>
<td colspan="5"></td>
<td>- {{ cart.get_max }} бал.</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="Использовать" />
</form>
<form action="{% url 'discount:revoke_points' %}" method="post">{% csrf_token %}
<input type="submit" name="points" value="Отменить" />
</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 %}