86 lines
4.3 KiB
PHP
86 lines
4.3 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
/** @var array<string, mixed> $product */
|
||
/** @var array<int, array<string, mixed>> $variants */
|
||
/** @var array<int, array<string, mixed>> $images */
|
||
|
||
$mainImage = $product['main_image_path'] ?? '';
|
||
?>
|
||
<section
|
||
class="product-detail price-aware"
|
||
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'] ?? '')) ?>"
|
||
>
|
||
<div class="product-gallery panel">
|
||
<?php if ($mainImage !== ''): ?>
|
||
<img src="<?= e((string) $mainImage) ?>" alt="<?= e((string) $product['name']) ?>">
|
||
<?php else: ?>
|
||
<div class="product-image-placeholder">Рыбсток</div>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($images !== []): ?>
|
||
<div class="product-thumbs">
|
||
<?php foreach ($images as $image): ?>
|
||
<img src="<?= e((string) $image['path']) ?>" alt="<?= e((string) ($image['alt'] ?: $product['name'])) ?>">
|
||
<?php endforeach; ?>
|
||
</div>
|
||
<?php endif; ?>
|
||
</div>
|
||
|
||
<article class="product-detail-main panel">
|
||
<p class="eyebrow"><?= e((string) ($product['category_name'] ?? 'Каталог')) ?></p>
|
||
<h1><?= e((string) ($product['h1'] ?: $product['name'])) ?></h1>
|
||
|
||
<?php if (!empty($product['short_description'])): ?>
|
||
<p class="product-lead"><?= e((string) $product['short_description']) ?></p>
|
||
<?php endif; ?>
|
||
|
||
<?php if ($variants !== []): ?>
|
||
<section class="variant-list" aria-label="Фасовки товара">
|
||
<h2>Фасовки</h2>
|
||
<?php foreach ($variants as $variant): ?>
|
||
<div
|
||
class="variant-row"
|
||
data-variant-id="<?= e((string) ($variant['id'] ?? '')) ?>"
|
||
data-variant-name="<?= e((string) ($variant['name'] ?? '')) ?>"
|
||
data-base-unit-price="<?= e((string) ($variant['price_per_unit'] ?? '')) ?>"
|
||
data-base-package-price="<?= e((string) ($variant['package_price'] ?? '')) ?>"
|
||
>
|
||
<strong><?= e((string) $variant['name']) ?></strong>
|
||
<span>
|
||
<?php if ($variant['price_per_unit'] !== null): ?>
|
||
<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>
|
||
<?php if (!empty($variant['old_package_price'])): ?>
|
||
<span class="old-price"><?= e(money_label($variant['old_package_price'])) ?></span>
|
||
<?php endif; ?>
|
||
<span data-dynamic-package-price data-base-package-price="<?= e((string) $variant['package_price']) ?>"><?= e(money_label($variant['package_price'])) ?></span>
|
||
</b>
|
||
<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>
|
||
</div>
|
||
<?php endforeach; ?>
|
||
</section>
|
||
<?php endif; ?>
|
||
</article>
|
||
|
||
<?php if (!empty($product['description'])): ?>
|
||
<section class="product-description panel">
|
||
<h2>Описание</h2>
|
||
<?= (string) $product['description'] ?>
|
||
</section>
|
||
<?php endif; ?>
|
||
</section>
|