отображение ненужных цен за кг
This commit is contained in:
+89
-13
@@ -8,6 +8,7 @@ declare(strict_types=1);
|
||||
/** @var array<string, mixed> $pagination */
|
||||
|
||||
$heading = $currentCategory['h1'] ?? $currentCategory['name'] ?? 'Каталог продукции';
|
||||
$categoryDescription = trim((string) ($currentCategory['description'] ?? ''));
|
||||
$pagination = $pagination ?? [
|
||||
'base_path' => '/catalog',
|
||||
'total' => count($products),
|
||||
@@ -21,14 +22,28 @@ $pagination = $pagination ?? [
|
||||
?>
|
||||
<section class="catalog-layout">
|
||||
<aside class="catalog-sidebar">
|
||||
<div class="panel sticky-panel">
|
||||
<h2>Категории</h2>
|
||||
<?php
|
||||
$items = $categories;
|
||||
$depth = 0;
|
||||
$currentSlug = $currentCategory['slug'] ?? '';
|
||||
require base_path('views/partials/category-tree.php');
|
||||
?>
|
||||
<div class="catalog-side-stack">
|
||||
<div class="panel catalog-menu-panel">
|
||||
<div class="catalog-side-heading">
|
||||
<span>Каталог</span>
|
||||
<small><?= e((string) $pagination['total']) ?> позиций</small>
|
||||
</div>
|
||||
<?php
|
||||
$items = $categories;
|
||||
$depth = 0;
|
||||
$currentSlug = $currentCategory['slug'] ?? '';
|
||||
require base_path('views/partials/category-tree.php');
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="panel catalog-mini-cart" data-mini-cart>
|
||||
<div>
|
||||
<span>Корзина</span>
|
||||
<strong data-mini-cart-total>0 руб.</strong>
|
||||
</div>
|
||||
<p><span data-mini-cart-count>0</span> позиций</p>
|
||||
<a href="/cart">Перейти</a>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
@@ -36,13 +51,65 @@ $pagination = $pagination ?? [
|
||||
<div class="catalog-heading">
|
||||
<p class="eyebrow"><?= $currentCategory === null ? 'Полный каталог' : 'Категория' ?></p>
|
||||
<h1><?= e($heading) ?></h1>
|
||||
<?php if (!empty($currentCategory['description'])): ?>
|
||||
<p><?= e($currentCategory['description']) ?></p>
|
||||
<?php else: ?>
|
||||
<p class="muted">Выберите категорию слева или смотрите товары сразу в каталоге.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<section class="payment-benefit-banner cash-benefit-banner" aria-label="Выгода при оплате наличными">
|
||||
<div class="cash-benefit-copy">
|
||||
<p class="eyebrow">Выгода считается автоматически</p>
|
||||
<h2>Оплачивайте наличными при получении и получайте лучшие условия</h2>
|
||||
<p>Добавляйте товары в корзину, а сайт сам пересчитает итог от суммы заказа. Ничего считать вручную не нужно.</p>
|
||||
</div>
|
||||
<div class="cash-receipt" aria-hidden="true">
|
||||
<div class="cash-receipt-top">
|
||||
<span>Чек выгоды</span>
|
||||
<strong>Рыбсток</strong>
|
||||
</div>
|
||||
<dl>
|
||||
<div>
|
||||
<dt>от 7 000р.</dt>
|
||||
<dd>-300р.</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>от 20 000р.</dt>
|
||||
<dd>-5%</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>от 50 000р.</dt>
|
||||
<dd>-7%</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<small>Пересчет появится в корзине сразу</small>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="payment-benefit-banner qr-benefit-banner" aria-label="Преимущество оплаты QR-кодом">
|
||||
<div class="cash-benefit-copy">
|
||||
<p class="eyebrow">Удобная оплата при получении</p>
|
||||
<h2>Принимаем оплату QR-кодом без комиссии даже с кредитной карты</h2>
|
||||
<p>После подтверждения заказа менеджер согласует получение, а при передаче товара можно оплатить QR-кодом без лишних комиссий.</p>
|
||||
</div>
|
||||
<div class="payment-benefit-card" aria-hidden="true">
|
||||
<span>QR-оплата</span>
|
||||
<strong>0%</strong>
|
||||
<p>комиссия для покупателя</p>
|
||||
<small>Наличными пользоваться необязательно</small>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="payment-benefit-banner invoice-benefit-banner" aria-label="Оплата по расчетному счету">
|
||||
<div class="cash-benefit-copy">
|
||||
<p class="eyebrow">Для организаций и крупных заказов</p>
|
||||
<h2>Счет на оплату выставляем день в день</h2>
|
||||
<p>После подтверждения заказа менеджер подготовит счет и согласует документы. Безналичный расчет доступен для заказов от 30 000р.</p>
|
||||
</div>
|
||||
<div class="payment-benefit-card" aria-hidden="true">
|
||||
<span>Расчетный счет</span>
|
||||
<strong>день в день</strong>
|
||||
<p>после подтверждения заказа</p>
|
||||
<small>Документы согласуем с менеджером</small>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php if ($products === []): ?>
|
||||
<div class="panel">
|
||||
<p class="muted">В этой категории товары появятся после переноса каталога со старого сайта.</p>
|
||||
@@ -74,5 +141,14 @@ $pagination = $pagination ?? [
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($categoryDescription !== ''): ?>
|
||||
<section class="catalog-seo-panel">
|
||||
<h2><?= e($heading) ?></h2>
|
||||
<div class="catalog-seo-content">
|
||||
<?= (string) $categoryDescription ?>
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -7,6 +7,31 @@ declare(strict_types=1);
|
||||
/** @var array<int, array<string, mixed>> $images */
|
||||
|
||||
$mainImage = $product['main_image_path'] ?? '';
|
||||
$showUnitPriceForVariant = static function (array $variant) use ($product): bool {
|
||||
if (function_exists('product_should_show_unit_price')) {
|
||||
return product_should_show_unit_price($product, $variant);
|
||||
}
|
||||
|
||||
$unit = (string) ($variant['unit'] ?? $product['base_unit'] ?? '');
|
||||
if (!in_array($unit, ['kg', 'кг'], true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (($variant['price_per_unit'] ?? null) === null || (float) $variant['price_per_unit'] <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$packageQuantity = (float) ($variant['package_quantity'] ?? 0);
|
||||
if ($packageQuantity < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$lower = static function (string $value): string {
|
||||
return function_exists('mb_strtolower') ? mb_strtolower($value, 'UTF-8') : strtolower($value);
|
||||
};
|
||||
|
||||
return preg_match('/(^|[\s,.;])\d+(?:[.,]\d+)?\s*(мл|шт)\.?($|[\s,.;])/u', $lower((string) ($variant['name'] ?? ''))) !== 1;
|
||||
};
|
||||
?>
|
||||
<section
|
||||
class="product-detail price-aware"
|
||||
@@ -43,6 +68,7 @@ $mainImage = $product['main_image_path'] ?? '';
|
||||
<section class="variant-list" aria-label="Фасовки товара">
|
||||
<h2>Фасовки</h2>
|
||||
<?php foreach ($variants as $variant): ?>
|
||||
<?php $showUnitPrice = $showUnitPriceForVariant($variant); ?>
|
||||
<div
|
||||
class="variant-row"
|
||||
data-variant-id="<?= e((string) ($variant['id'] ?? '')) ?>"
|
||||
@@ -52,11 +78,12 @@ $mainImage = $product['main_image_path'] ?? '';
|
||||
>
|
||||
<strong><?= e((string) $variant['name']) ?></strong>
|
||||
<span>
|
||||
<?php if ($variant['price_per_unit'] !== null): ?>
|
||||
<?php if ($showUnitPrice): ?>
|
||||
<span data-dynamic-unit-price data-base-unit-price="<?= e((string) $variant['price_per_unit']) ?>"><?= e(money_label($variant['price_per_unit'])) ?></span> / <?= e(unit_label((string) $variant['unit'])) ?>
|
||||
<?php endif; ?>
|
||||
</span>
|
||||
<b>
|
||||
<small>За фасовку <?= e((string) $variant['name']) ?></small>
|
||||
<?php if (!empty($variant['old_package_price'])): ?>
|
||||
<span class="old-price"><?= e(money_label($variant['old_package_price'])) ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user