Files
santeh-ray/templates/orders/cart.html
Azimkin 1188cef7be
All checks were successful
Build and Push Docker Image / build (push) Successful in 27s
Make product cards fully clickable
2026-06-16 00:06:21 +02:00

230 lines
16 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "_layouts/base.html" %}
{% load static l10n %}
{% block title %}{% if direct_checkout %}Оформление заказа{% else %}Корзина{% endif %}{% endblock %}
{% block add_css %}
<link rel="stylesheet" href="{% static "css/cart.css" %}">
{% endblock %}
{% block content %}
{% include "_fragments/header.html" %}
{% if direct_checkout %}
{% include '_fragments/breadcrumbs.html' with url_1='/' text_1='Главная' url_2=request.path text_2='Оформление заказа' %}
{% else %}
{% include '_fragments/breadcrumbs.html' with url_1='/' text_1='Главная' url_2='/orders/cart/' text_2='Корзина' %}
{% endif %}
<main class="container cart-page">
{% if cart_items %}
<div class="checkout-layout">
<section class="cart-products" aria-label="Товары в корзине">
<h1 class="cart-section-title">ТОВАРЫ</h1>
<div class="cart-items">
{% for cart_item in cart_items %}
{% with item=cart_item.item %}
{% url 'detail' item.category.slug item.slug as item_url %}
<article class="cart-item" data-auth-cart-item data-current-quantity="{{ cart_item.quantity }}">
<a class="cart-item__overlay" href="{{ item_url }}" aria-label="Открыть товар {{ item.name }}" tabindex="-1" aria-hidden="true"></a>
<a class="cart-item__media" href="{{ item_url }}">
{% with primary_image=item.primary_image %}
{% if primary_image %}
<img src="{{ primary_image.image.url }}" alt="{{ primary_image.alt|default:item.name }}">
{% else %}
<span class="cart-item__placeholder">Нет фото</span>
{% endif %}
{% endwith %}
</a>
<div class="cart-item__info">
<a class="cart-item__title" href="{{ item_url }}">{{ item.name }}</a>
{% if cart_item.selected_color %}
<span class="cart-item__color">({{ cart_item.selected_color.name }})</span>
{% endif %}
<p class="cart-item__price">{{ item.price }} руб.</p>
{% if direct_checkout %}
<div class="cart-item__controls">
<div class="cart-quantity" aria-label="Количество товара">
<span class="cart-quantity__value">{{ cart_item.quantity }}</span>
</div>
</div>
{% else %}
<div class="cart-item__controls">
<div class="cart-quantity" aria-label="Количество товара">
<button
class="cart-quantity__button"
type="button"
data-cart-decrement
data-remove-form-id="cart-remove-{{ cart_item.id }}"
data-update-form-id="cart-decrement-{{ cart_item.id }}"
data-current-quantity="{{ cart_item.quantity }}"
aria-label="Уменьшить количество"
>
-
</button>
<span class="cart-quantity__value">{{ cart_item.quantity }}</span>
<form id="cart-increment-{{ cart_item.id }}" method="post" action="{% url 'orders:update_quantity' %}">
{% csrf_token %}
<input type="hidden" name="item_id" value="{{ item.id }}">
<input type="hidden" name="quantity" value="{{ cart_item.quantity|add:1 }}">
<input type="hidden" name="next" value="{% url 'orders:cart' %}">
<button class="cart-quantity__button" type="submit" aria-label="Увеличить количество">+</button>
</form>
<form id="cart-decrement-{{ cart_item.id }}" method="post" action="{% url 'orders:update_quantity' %}">
{% csrf_token %}
<input type="hidden" name="item_id" value="{{ item.id }}">
<input type="hidden" name="quantity" value="{{ cart_item.quantity|add:-1 }}">
<input type="hidden" name="next" value="{% url 'orders:cart' %}">
</form>
</div>
<form id="cart-remove-{{ cart_item.id }}" method="post" action="{% url 'orders:remove' %}">
{% csrf_token %}
<input type="hidden" name="item_id" value="{{ item.id }}">
<input type="hidden" name="next" value="{% url 'orders:cart' %}">
<button class="cart-item__remove" type="submit" aria-label="Удалить товар">Удалить</button>
</form>
</div>
{% endif %}
</div>
</article>
{% endwith %}
{% endfor %}
</div>
<div class="cart-products-summary">
<p><span>Товары, {{ total_quantity }} шт.</span><strong>{{ products_total }}</strong></p>
<p><span>Скидка</span><strong>{{ discount_total }}</strong></p>
<p><span>Итого к оплате</span><strong data-checkout-total-text>{{ total_amount }}</strong></p>
</div>
</section>
<section class="checkout-panel" aria-label="Оформление заказа">
<h2 class="cart-section-title">Оформление заказа</h2>
<form
class="checkout-form"
method="post"
action="{% if direct_checkout %}{% url 'orders:buy_now' direct_item.id %}{% else %}{% url 'orders:checkout' %}{% endif %}"
data-checkout-form
data-products-total="{{ products_total_value|unlocalize }}"
>
{% csrf_token %}
{% if checkout_form.non_field_errors %}
<div class="checkout-errors">
{% for error in checkout_form.non_field_errors %}
<p>{{ error }}</p>
{% endfor %}
</div>
{% endif %}
<fieldset class="checkout-fieldset">
<legend>СПОСОБ ДОСТАВКИ</legend>
<div class="checkout-options checkout-options--two">
<label class="checkout-radio">
<input type="radio" name="delivery_method" value="courier" required {% if checkout_form.delivery_method.value == "courier" or not checkout_form.is_bound %}checked{% endif %}>
<span>Курьерская доставка</span>
</label>
<label class="checkout-radio">
<input type="radio" name="delivery_method" value="pickup" required {% if checkout_form.delivery_method.value == "pickup" %}checked{% endif %}>
<span>Самовывоз</span>
</label>
</div>
{% for error in checkout_form.delivery_method.errors %}<p class="field-error">{{ error }}</p>{% endfor %}
</fieldset>
<fieldset class="checkout-fieldset">
<legend>АДРЕС ДОСТАВКИ</legend>
<div class="checkout-grid">
<label class="checkout-input checkout-input--short">
<span>Регион*</span>
<input type="text" name="region" value="{{ checkout_form.region.value|default:'' }}" placeholder="Регион*" autocomplete="address-level1">
</label>
<label class="checkout-input checkout-input--wide">
<span>Улица, дом, квартира*</span>
<input type="text" name="address" value="{{ checkout_form.address.value|default:'' }}" placeholder="Улица, дом, квартира*" autocomplete="street-address">
</label>
</div>
{% for error in checkout_form.region.errors %}<p class="field-error">{{ error }}</p>{% endfor %}
{% for error in checkout_form.address.errors %}<p class="field-error">{{ error }}</p>{% endfor %}
</fieldset>
<fieldset class="checkout-fieldset">
<legend>СПОСОБ ОПЛАТЫ</legend>
<div class="checkout-options checkout-options--two">
<label class="checkout-radio">
<input type="radio" name="payment_method" value="cash" required {% if checkout_form.payment_method.value == "cash" or not checkout_form.is_bound %}checked{% endif %}>
<span>Наличкой при получении</span>
</label>
<label class="checkout-radio">
<input type="radio" name="payment_method" value="card" required {% if checkout_form.payment_method.value == "card" %}checked{% endif %}>
<span>Картой при получении</span>
</label>
</div>
{% for error in checkout_form.payment_method.errors %}<p class="field-error">{{ error }}</p>{% endfor %}
</fieldset>
<fieldset class="checkout-fieldset">
<legend>КОНТАКТЫ</legend>
<div class="checkout-grid checkout-grid--contacts">
<label class="checkout-input checkout-input--wide">
<span>ФИО*</span>
<input type="text" name="customer_name" value="{{ checkout_form.customer_name.value|default:'' }}" placeholder="ФИО*" autocomplete="name" required>
</label>
<label class="checkout-input">
<span>Телефон*</span>
<input type="tel" name="phone" value="{{ checkout_form.phone.value|default:'' }}" placeholder="Телефон*" autocomplete="tel" inputmode="tel" pattern="\+?[\d\s\-()]{7,20}" required>
</label>
<label class="checkout-input">
<span>E-mail*</span>
<input type="email" name="email" value="{{ checkout_form.email.value|default:'' }}" placeholder="E-mail*" autocomplete="email" required>
</label>
</div>
{% for error in checkout_form.customer_name.errors %}<p class="field-error">{{ error }}</p>{% endfor %}
{% for error in checkout_form.phone.errors %}<p class="field-error">{{ error }}</p>{% endfor %}
{% for error in checkout_form.email.errors %}<p class="field-error">{{ error }}</p>{% endfor %}
<label class="checkout-checkbox">
<input type="checkbox" name="recipient_matches_customer" value="on" {% if checkout_form.recipient_matches_customer.value or not checkout_form.is_bound %}checked{% endif %}>
<span>ФИО получателя совпадает с ФИО покупателя</span>
</label>
</fieldset>
<div class="checkout-summary">
<p><strong>Товары, {{ total_quantity }} шт.</strong><span>{{ products_total }}</span></p>
<p><strong>Скидка</strong><span>{{ discount_total }}</span></p>
<p><strong>Итого к оплате</strong><span data-checkout-total-text>{{ total_amount }}</span></p>
</div>
<button class="checkout-submit" type="submit">ОФОРМИТЬ ЗАКАЗ</button>
<label class="checkout-checkbox checkout-checkbox--terms">
<input type="checkbox" name="terms_accepted" value="on" required {% if checkout_form.terms_accepted.value %}checked{% endif %}>
<span>Согласен с условиями продажи, оплаты и возврата</span>
</label>
{% for error in checkout_form.terms_accepted.errors %}<p class="field-error">{{ error }}</p>{% endfor %}
<div class="checkout-services">
<h3>Услуги</h3>
<p><span>Доставка</span><strong data-delivery-total-text>{{ delivery_total }}</strong></p>
<p><span>Подъём на этаж</span><strong data-floor-lift-total-text>{{ floor_lift_total }}</strong></p>
</div>
</form>
</section>
</div>
{% else %}
<section class="cart-empty">
<h1>Корзина пуста</h1>
<p>Добавьте товары из каталога, чтобы оформить заказ.</p>
<a href="/catalog/">Перейти в каталог</a>
</section>
{% endif %}
</main>
{% include "_fragments/footer.html" %}
{% endblock %}