Files
new.rybstock.ru/views/catalog/product.php
T
2026-06-05 15:52:20 +03:00

79 lines
3.7 KiB
PHP
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.
<?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>
<button class="add-to-cart-button" type="button">В корзину</button>
</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>