Files
shop10/src/views/cart.ejs
T
shop 0c2cee410f ui: иконки и наглядное отображение цен со скидкой
SVG-иконки в шапке и кнопках, зачёркнутая старая цена и акцент на цене со скидкой в каталоге, корзине и на карточке товара.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-17 14:14:38 +03:00

126 lines
5.5 KiB
Plaintext
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.
<%- include('partials/layout-start') %>
<h1>Корзина</h1>
<% if (error) { %><p class="alert alert--error"><%= error %></p><% } %>
<% if (promoOk) { %><p class="alert alert--success"><%= promoOk %></p><% } %>
<% if (promoErr) { %><p class="alert alert--error"><%= promoErr %></p><% } %>
<% if (!items.length) { %>
<p class="empty">Корзина пуста. <a href="/">Перейти в каталог</a></p>
<% } else { %>
<form action="/cart/update" method="post" class="cart-table-wrap">
<table class="cart-table">
<thead>
<tr>
<th>Товар</th>
<th>Цена</th>
<th>Кол-во</th>
<th>Сумма</th>
<th></th>
</tr>
</thead>
<tbody>
<% items.forEach(item => { %>
<tr>
<td class="cart-table__product">
<% if (item.image_url) { %>
<img src="<%= item.image_url %>" alt="" class="cart-table__thumb">
<% } %>
<a href="/product/<%= item.slug %>"><%= item.name %></a>
</td>
<td class="cart-table__price">
<%- include('partials/product-price', {
product: item,
forceOnSale: item.on_sale,
forceEffective: item.effective_price_cents,
priceSize: 'sm'
}) %>
</td>
<td>
<input type="number" name="items[<%= item.id %>]" value="<%= item.quantity %>" min="0" max="<%= item.stock %>" class="input input--qty">
</td>
<td><%= formatPrice(item.line_total) %></td>
<td>
<button type="submit" formaction="/cart/remove/<%= item.id %>" formmethod="post" class="btn btn--ghost btn--sm btn--icon" title="Удалить" aria-label="Удалить">
<%- include('partials/icon', { name: 'trash', iconSize: 16 }) %>
</button>
</td>
</tr>
<% }) %>
</tbody>
</table>
<div class="cart-sidebar">
<section class="card promo-box">
<h2 class="promo-box__title">Промокод</h2>
<% if (pricing.promo) { %>
<p class="promo-box__applied">
<strong><%= pricing.promo.code %></strong>
<% if (pricing.promo.description) { %> — <%= pricing.promo.description %><% } %>
</p>
<p class="promo-box__discount">Скидка: <%= formatPrice(pricing.promoDiscount) %></p>
<div class="promo-countdown" data-expires="<%= pricing.promo.expires_at %>">
<span class="promo-countdown__label">До конца акции:</span>
<span class="promo-countdown__timer">—</span>
</div>
<form action="/cart/promo/remove" method="post" class="inline-form">
<button type="submit" class="btn btn--ghost btn--sm">Убрать промокод</button>
</form>
<% } else { %>
<form action="/cart/promo" method="post" class="promo-box__form">
<input type="text" name="code" class="input" placeholder="WELCOME10" required autocomplete="off">
<button type="submit" class="btn btn--primary">Применить</button>
</form>
<% } %>
</section>
<% if (user) { %>
<section class="card promo-box">
<h2 class="promo-box__title">Баллы лояльности</h2>
<p class="muted">На счёте: <strong><%= pricing.loyaltyBalance %></strong> баллов (1 балл = 1 коп.)</p>
<% if (pricing.pointsEarned > 0) { %>
<p class="muted">За этот заказ начислим: +<%= pricing.pointsEarned %> баллов</p>
<% } %>
<% if (pricing.loyaltyDiscount > 0) { %>
<p class="promo-box__discount">Списано: <%= formatPrice(pricing.loyaltyDiscount) %> (<%= pricing.loyaltyPointsUsed %> баллов)</p>
<form action="/cart/loyalty/remove" method="post">
<button type="submit" class="btn btn--ghost btn--sm">Отменить списание</button>
</form>
<% } else if (pricing.loyaltyBalance > 0) { %>
<form action="/cart/loyalty" method="post" class="promo-box__form">
<button type="submit" name="use_all" value="1" class="btn btn--ghost">Списать все доступные</button>
</form>
<% } %>
</section>
<% } %>
<section class="card cart-summary">
<dl class="cart-summary__dl">
<dt>Товары</dt>
<dd><%= formatPrice(pricing.subtotal) %></dd>
<% if (pricing.promoDiscount > 0) { %>
<dt>Промокод</dt>
<dd class="cart-summary__discount"><%= formatPrice(pricing.promoDiscount) %></dd>
<% } %>
<% if (pricing.loyaltyDiscount > 0) { %>
<dt>Лояльность</dt>
<dd class="cart-summary__discount"><%= formatPrice(pricing.loyaltyDiscount) %></dd>
<% } %>
<dt class="cart-summary__total-label">К оплате</dt>
<dd class="cart-summary__total"><%= formatPrice(pricing.total) %></dd>
</dl>
<% if (user) { %>
<a href="/checkout" class="btn btn--primary btn--lg btn--block">Оформить заказ</a>
<% } else { %>
<p class="hint"><a href="/login?next=/checkout">Войдите</a>, чтобы оформить заказ.</p>
<% } %>
</section>
</div>
</form>
<% } %>
<script src="/js/promo-countdown.js"></script>
<%- include('partials/layout-end') %>