баги с превью
This commit is contained in:
@@ -5,8 +5,19 @@ declare(strict_types=1);
|
||||
/** @var array<int, array<string, mixed>> $categories */
|
||||
/** @var array<string, mixed>|null $currentCategory */
|
||||
/** @var array<int, array<string, mixed>> $products */
|
||||
/** @var array<string, mixed> $pagination */
|
||||
|
||||
$heading = $currentCategory['h1'] ?? $currentCategory['name'] ?? 'Каталог продукции';
|
||||
$pagination = $pagination ?? [
|
||||
'base_path' => '/catalog',
|
||||
'total' => count($products),
|
||||
'shown' => count($products),
|
||||
'page' => 1,
|
||||
'pages' => 1,
|
||||
'per_page' => 48,
|
||||
'has_more' => false,
|
||||
'next_limit' => count($products),
|
||||
];
|
||||
?>
|
||||
<section class="catalog-layout">
|
||||
<aside class="catalog-sidebar">
|
||||
@@ -37,11 +48,31 @@ $heading = $currentCategory['h1'] ?? $currentCategory['name'] ?? 'Каталог
|
||||
<p class="muted">В этой категории товары появятся после переноса каталога со старого сайта.</p>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="catalog-count-panel">
|
||||
<span>Показано <?= e((string) $pagination['shown']) ?> из <?= e((string) $pagination['total']) ?> товаров</span>
|
||||
<?php if (!empty($pagination['has_more'])): ?>
|
||||
<a href="<?= e((string) $pagination['base_path']) ?>?limit=<?= e((string) $pagination['next_limit']) ?>">Показать еще</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="product-grid catalog-product-grid">
|
||||
<?php foreach ($products as $product): ?>
|
||||
<?php require base_path('views/partials/product-card.php'); ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ((int) $pagination['pages'] > 1): ?>
|
||||
<nav class="catalog-pagination" aria-label="Страницы каталога">
|
||||
<?php for ($pageNumber = 1; $pageNumber <= (int) $pagination['pages']; $pageNumber++): ?>
|
||||
<a
|
||||
class="<?= $pageNumber === (int) $pagination['page'] && empty($pagination['cumulative']) ? 'is-current' : '' ?>"
|
||||
href="<?= e((string) $pagination['base_path']) ?>?page=<?= e((string) $pageNumber) ?>"
|
||||
>
|
||||
<?= e((string) $pageNumber) ?>
|
||||
</a>
|
||||
<?php endfor; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -521,6 +521,17 @@ try {
|
||||
}, 1200);
|
||||
});
|
||||
|
||||
document.addEventListener('click', (event) => {
|
||||
const notifyButton = event.target.closest('[data-notify-arrival]');
|
||||
|
||||
if (!notifyButton) {
|
||||
return;
|
||||
}
|
||||
|
||||
notifyButton.classList.add('is-sent');
|
||||
notifyButton.textContent = 'Запрос принят';
|
||||
});
|
||||
|
||||
document.addEventListener('click', (event) => {
|
||||
const control = event.target.closest('[data-cart-plus], [data-cart-minus], [data-cart-remove]');
|
||||
|
||||
|
||||
@@ -31,27 +31,48 @@ if ($activeOldUnitPrice !== null && $activeOldUnitPrice <= $activeUnitPrice) {
|
||||
}
|
||||
$activeTierBase = $activeUnitPrice ?? $activePackagePrice;
|
||||
$activeTierUnit = unit_label((string) ($activeVariant['unit'] ?? '')) ?: 'шт.';
|
||||
$isPublished = (int) ($product['is_published'] ?? 1) === 1;
|
||||
$isAvailable = (int) ($product['is_available'] ?? 1) === 1;
|
||||
$isPurchasable = $isPublished && $isAvailable && $activePackagePrice > 0;
|
||||
?>
|
||||
<article
|
||||
class="product-card price-aware"
|
||||
class="product-card price-aware<?= $isPurchasable ? '' : ' is-unavailable' ?>"
|
||||
id="<?= e($cardId) ?>"
|
||||
data-product-id="<?= e((string) ($product['id'] ?? '')) ?>"
|
||||
data-product-name="<?= e((string) ($product['name'] ?? '')) ?>"
|
||||
data-product-slug="<?= e((string) ($product['slug'] ?? '')) ?>"
|
||||
data-product-image="<?= e((string) ($product['main_image_path'] ?? '')) ?>"
|
||||
>
|
||||
<?php if (!empty($product['main_image_path'])): ?>
|
||||
<?php if (!$isPurchasable): ?>
|
||||
<span class="product-unavailable-badge"><?= !$isPublished ? 'Ожидается поступление' : 'Нет в наличии' ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($product['main_image_path']) && $isPurchasable): ?>
|
||||
<a class="product-card-image" href="/product/<?= e($product['slug']) ?>" aria-label="<?= e($product['name']) ?>">
|
||||
<img src="<?= e((string) $product['main_image_path']) ?>" alt="<?= e((string) $product['name']) ?>">
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<?php elseif (!empty($product['main_image_path'])): ?>
|
||||
<div class="product-card-image" aria-label="<?= e($product['name']) ?>">
|
||||
<img src="<?= e((string) $product['main_image_path']) ?>" alt="<?= e((string) $product['name']) ?>">
|
||||
</div>
|
||||
<?php elseif ($isPurchasable): ?>
|
||||
<a class="product-card-image product-card-image-placeholder" href="/product/<?= e($product['slug']) ?>" aria-label="<?= e($product['name']) ?>">
|
||||
<span>Рыбсток</span>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<div class="product-card-image product-card-image-placeholder" aria-label="<?= e($product['name']) ?>">
|
||||
<span>Рыбсток</span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="product-category"><?= e($product['category_display_name'] ?? $product['category_name'] ?? 'Каталог') ?></p>
|
||||
<h3><a href="/product/<?= e($product['slug']) ?>"><?= e($product['name']) ?></a></h3>
|
||||
<h3>
|
||||
<?php if ($isPurchasable): ?>
|
||||
<a href="/product/<?= e($product['slug']) ?>"><?= e($product['name']) ?></a>
|
||||
<?php else: ?>
|
||||
<span><?= e($product['name']) ?></span>
|
||||
<?php endif; ?>
|
||||
</h3>
|
||||
|
||||
<?php if ($variants !== []): ?>
|
||||
<div class="variant-choice" aria-label="Выбор фасовки">
|
||||
@@ -97,45 +118,58 @@ $activeTierUnit = unit_label((string) ($activeVariant['unit'] ?? '')) ?: 'шт.'
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($activeVariant['price_per_unit'] !== null): ?>
|
||||
<?php if ($isPurchasable && $activeVariant['price_per_unit'] !== null): ?>
|
||||
<span class="price-line">
|
||||
<span class="price-unit-label">Цена за <span data-unit-label><?= e(unit_label((string) $activeVariant['unit'])) ?></span>:</span>
|
||||
<span class="price-unit-values">
|
||||
<span class="old-price" data-old-unit-price-display<?= $activeOldUnitPrice === null ? ' hidden' : '' ?>><?= e(money_label($activeOldUnitPrice)) ?></span>
|
||||
<b data-price-unit data-dynamic-unit-price data-base-unit-price="<?= e((string) $activeUnitPrice) ?>"><?= e(money_label($activeVariant['price_per_unit'])) ?></b>
|
||||
<?php if ($isPurchasable): ?>
|
||||
<button class="price-tier-trigger" type="button" aria-label="Показать градацию цены">?</button>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<button class="price-tier-trigger" type="button" aria-label="Показать градацию цены">?</button>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($activeVariant['package_price'] !== null): ?>
|
||||
<?php if ($isPurchasable && $activeVariant['package_price'] !== null): ?>
|
||||
<strong class="package-price-line">
|
||||
<span class="package-price-label">За фасовку <span data-package-label-display><?= e((string) $activeVariant['name']) ?></span>:</span>
|
||||
<span class="package-price-values">
|
||||
<span class="old-price" data-old-package-price-display<?= $activeOldPackagePrice === null ? ' hidden' : '' ?>><?= e(money_label($activeOldPackagePrice)) ?></span>
|
||||
<span data-package-price data-dynamic-package-price data-base-package-price="<?= e((string) $activePackagePrice) ?>"><?= e(money_label($activeVariant['package_price'])) ?></span>
|
||||
<?php if ($activeVariant['price_per_unit'] === null): ?>
|
||||
<button class="price-tier-trigger" type="button" aria-label="Показать градацию цены">?</button>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
</strong>
|
||||
<?php if ($activeVariant['price_per_unit'] !== null): ?>
|
||||
<span class="package-price-note">Цена за <span data-unit-label-note><?= e(unit_label((string) $activeVariant['unit'])) ?></span> × <span data-package-label-note><?= e((string) $activeVariant['name']) ?></span></span>
|
||||
<?php endif; ?>
|
||||
<?php elseif (!$isPurchasable): ?>
|
||||
<div class="product-card-unavailable-note">Цену уточним после поступления товара.</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="price-tier-popover" role="tooltip">
|
||||
<strong>Варианты цены за <span data-tier-unit-label><?= e($activeTierUnit) ?></span> при наличном расчете:</strong>
|
||||
<dl>
|
||||
<div><dt>Базовая цена</dt><dd data-tier-base><?= e(money_label($activeTierBase)) ?></dd></div>
|
||||
<div><dt>При заказе от 20 000р.</dt><dd data-tier-cash-20><?= e(money_label(floor($activeTierBase * 0.95))) ?></dd></div>
|
||||
<div><dt>При заказе от 50 000р.</dt><dd data-tier-cash-50><?= e(money_label(floor($activeTierBase * 0.93))) ?></dd></div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="product-card-actions">
|
||||
<div class="quantity-stepper" data-quantity-control aria-label="Количество фасовок">
|
||||
<button type="button" data-quantity-minus aria-label="Уменьшить количество">-</button>
|
||||
<input data-quantity-input type="text" inputmode="numeric" value="1" aria-label="Количество">
|
||||
<button type="button" data-quantity-plus aria-label="Увеличить количество">+</button>
|
||||
<?php if ($isPurchasable): ?>
|
||||
<div class="price-tier-popover" role="tooltip">
|
||||
<strong>Варианты цены за <span data-tier-unit-label><?= e($activeTierUnit) ?></span> при наличном расчете:</strong>
|
||||
<dl>
|
||||
<div><dt>Базовая цена</dt><dd data-tier-base><?= e(money_label($activeTierBase)) ?></dd></div>
|
||||
<div><dt>При заказе от 20 000р.</dt><dd data-tier-cash-20><?= e(money_label(floor($activeTierBase * 0.95))) ?></dd></div>
|
||||
<div><dt>При заказе от 50 000р.</dt><dd data-tier-cash-50><?= e(money_label(floor($activeTierBase * 0.93))) ?></dd></div>
|
||||
</dl>
|
||||
</div>
|
||||
<button class="add-to-cart-button" type="button">В корзину</button>
|
||||
</div>
|
||||
|
||||
<div class="product-card-actions">
|
||||
<div class="quantity-stepper" data-quantity-control aria-label="Количество фасовок">
|
||||
<button type="button" data-quantity-minus aria-label="Уменьшить количество">-</button>
|
||||
<input data-quantity-input type="text" inputmode="numeric" value="1" aria-label="Количество">
|
||||
<button type="button" data-quantity-plus aria-label="Увеличить количество">+</button>
|
||||
</div>
|
||||
<button class="add-to-cart-button" type="button">В корзину</button>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="product-card-actions">
|
||||
<button class="notify-arrival-button" type="button" data-notify-arrival>Сообщить о поступлении</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
|
||||
Reference in New Issue
Block a user