Files
apuc 37d5d7b366 Add the customer storefront on Django templates
Pages are rendered server-side (SEO, no build step), the interactive
parts talk to the existing REST API from the browser:

- home: banners, categories, hits and new arrivals
- catalog: filters (category, brand, price, stock), search, sorting,
  pagination, filter chips with one-click removal
- product card: gallery, price with discount, stock, characteristics,
  related products
- cart: localStorage, quantity controls, live totals
- checkout: contacts, delivery, promo code, bonuses, order submission
  with Idempotency-Key, success screen
- login: OTP by phone (debug code shown in dev) and phone/password
- account: profile, orders, addresses, bonuses through the API with JWT
- static pages from the admin

Supporting pieces:
- apps/storefront app with views, urls, templates and static CSS/JS
- money/discount/attribute template filters
- seed_demo management command with demo catalog, banners and pages
- Cyrillic search fallback for SQLite: local DB does not fold case for
  non-ASCII, production PostgreSQL does

Tests: 16 storefront cases (pages, filters, search, ordering, 404s,
filters formatting); the suite is 61 passing.
2026-11-22 22:38:39 +03:00

116 lines
5.6 KiB
HTML
Raw Permalink 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 "storefront/base.html" %}
{% load static storefront %}
{% block title %}Оформление заказа — {{ site.site_name }}{% endblock %}
{% block content %}
<div class="page-head">
<h1>Оформление заказа</h1>
</div>
<div class="cart-layout" data-checkout
data-free-threshold="{{ site.free_delivery_threshold|default:'0' }}"
data-delivery-cost="{{ site.default_delivery_cost|default:'0' }}"
data-bonus-limit="{{ site.bonus_max_payment_percent|default:'0' }}">
<div>
<form data-checkout-form novalidate>
<div class="account-panel" style="margin-bottom:20px">
<h2 style="font-size:20px">Контакты</h2>
<div class="field-row">
<div class="field">
<label for="customer_name">Имя и фамилия *</label>
<input id="customer_name" name="customer_name" required autocomplete="name">
</div>
<div class="field">
<label for="phone">Телефон *</label>
<input id="phone" name="phone" required autocomplete="tel" placeholder="+7 900 123-45-67">
</div>
</div>
<div class="field">
<label for="email">Email</label>
<input id="email" name="email" type="email" autocomplete="email" placeholder="для чека и уведомлений">
</div>
</div>
<div class="account-panel" style="margin-bottom:20px">
<h2 style="font-size:20px">Доставка</h2>
<div class="field">
<label for="delivery_method">Способ получения</label>
<select id="delivery_method" name="delivery_method">
<option value="courier">Курьером</option>
<option value="pickup">Самовывоз</option>
</select>
</div>
<div class="field" data-address-field>
<label for="delivery_address">Адрес</label>
<textarea id="delivery_address" name="delivery_address"
placeholder="Город, улица, дом, квартира"></textarea>
</div>
<div class="field">
<label for="comment">Комментарий к заказу</label>
<textarea id="comment" name="comment" placeholder="Например: позвонить за час"></textarea>
</div>
</div>
<div class="account-panel" style="margin-bottom:20px">
<h2 style="font-size:20px">Оплата</h2>
<div class="field">
<label for="payment_method">Способ оплаты</label>
<select id="payment_method" name="payment_method">
<option value="card">Картой онлайн</option>
<option value="sbp">СБП</option>
<option value="cash">При получении</option>
</select>
</div>
</div>
<div class="account-panel">
<h2 style="font-size:20px">Скидки</h2>
<div class="field">
<label for="promo_code">Промокод</label>
<div class="field-row">
<input id="promo_code" name="promo_code" placeholder="Например, WINTER15">
<button class="btn btn-outline" type="button" data-apply-promo>Применить</button>
</div>
<div class="form-note" data-promo-note></div>
</div>
<div class="field" data-bonus-field hidden>
<label for="bonus_amount">Списать бонусы (доступно: <span data-bonus-balance>0</span>)</label>
<input id="bonus_amount" name="bonus_amount" type="number" min="0" step="1" value="0">
<div class="form-note">Бонусами можно оплатить не более {{ site.bonus_max_payment_percent|floatformat:0 }}% заказа.</div>
</div>
</div>
<div class="form-error" data-checkout-error hidden></div>
</form>
</div>
<aside class="summary">
<h3>Ваш заказ</h3>
<div data-checkout-items></div>
<div class="summary-row"><span>Товары</span><span data-subtotal>0 ₽</span></div>
<div class="summary-row"><span>Скидка по промокоду</span><span data-discount>0 ₽</span></div>
<div class="summary-row"><span>Бонусы</span><span data-bonus>0 ₽</span></div>
<div class="summary-row"><span>Доставка</span><span data-delivery>0 ₽</span></div>
<div class="summary-row total"><span>К оплате</span><span data-total>0 ₽</span></div>
<button class="btn btn-accent btn-block" type="button" data-submit-order>Подтвердить заказ</button>
<p class="form-note" style="margin-top:10px">
Нажимая кнопку, вы соглашаетесь с условиями обработки персональных данных.
</p>
</aside>
</div>
<div class="account-panel" data-order-success hidden style="margin-top:24px">
<h2>Заказ оформлен</h2>
<p>Номер заказа: <strong data-order-number></strong></p>
<p class="form-note">Мы свяжемся с вами для подтверждения. Статус заказа виден в личном кабинете.</p>
<a class="btn btn-accent" href="{% url 'account' %}">Перейти в кабинет</a>
<a class="btn btn-outline" href="{% url 'catalog' %}">Вернуться в каталог</a>
</div>
{% endblock %}
{% block scripts %}
<script src="{% static 'storefront/js/checkout-page.js' %}" defer></script>
{% endblock %}