доставка в плавающем
This commit is contained in:
+79
-21
@@ -6,7 +6,13 @@ declare(strict_types=1);
|
||||
/** @var array<int, array<string, mixed>> $variants */
|
||||
/** @var array<int, array<string, mixed>> $images */
|
||||
|
||||
$mainImage = $product['main_image_path'] ?? '';
|
||||
$sourceMainImage = (string) ($product['main_image_path'] ?? '');
|
||||
$mainImage = function_exists('optimized_image_path')
|
||||
? optimized_image_path($sourceMainImage, 'detail')
|
||||
: $sourceMainImage;
|
||||
$cartImage = function_exists('optimized_image_path')
|
||||
? optimized_image_path($sourceMainImage, 'preview')
|
||||
: $sourceMainImage;
|
||||
$showUnitPriceForVariant = static function (array $variant) use ($product): bool {
|
||||
if (function_exists('product_should_show_unit_price')) {
|
||||
return product_should_show_unit_price($product, $variant);
|
||||
@@ -38,7 +44,7 @@ $showUnitPriceForVariant = static function (array $variant) use ($product): bool
|
||||
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'] ?? '')) ?>"
|
||||
data-product-image="<?= e($cartImage) ?>"
|
||||
>
|
||||
<div class="product-gallery panel">
|
||||
<?php if ($mainImage !== ''): ?>
|
||||
@@ -50,7 +56,12 @@ $showUnitPriceForVariant = static function (array $variant) use ($product): bool
|
||||
<?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
|
||||
$thumbPath = function_exists('optimized_image_path')
|
||||
? optimized_image_path((string) $image['path'], 'preview')
|
||||
: (string) $image['path'];
|
||||
?>
|
||||
<img src="<?= e($thumbPath) ?>" alt="<?= e((string) ($image['alt'] ?: $product['name'])) ?>" loading="lazy" decoding="async">
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
@@ -64,33 +75,78 @@ $showUnitPriceForVariant = static function (array $variant) use ($product): bool
|
||||
<p class="product-lead"><?= e((string) $product['short_description']) ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="product-detail-notes" aria-label="Условия заказа">
|
||||
<span>Оплата при получении</span>
|
||||
<span>Весовые позиции пересчитываем при сборке</span>
|
||||
<span>Доставка внутри МКАД бесплатно от 5000р.</span>
|
||||
</div>
|
||||
|
||||
<?php if ($variants !== []): ?>
|
||||
<section class="variant-list" aria-label="Фасовки товара">
|
||||
<h2>Фасовки</h2>
|
||||
<section class="variant-list product-detail-variants" aria-label="Фасовки товара">
|
||||
<h2>Доступные фасовки</h2>
|
||||
<?php foreach ($variants as $variant): ?>
|
||||
<?php $showUnitPrice = $showUnitPriceForVariant($variant); ?>
|
||||
<?php
|
||||
$showUnitPrice = $showUnitPriceForVariant($variant);
|
||||
$unitLabel = unit_label((string) ($variant['unit'] ?? $product['base_unit'] ?? 'кг'));
|
||||
$variantName = (string) ($variant['name'] ?? '');
|
||||
$packageQuantity = (float) ($variant['package_quantity'] ?? 0);
|
||||
$unitPrice = $variant['price_per_unit'] ?? null;
|
||||
$packagePrice = $variant['package_price'] ?? null;
|
||||
$oldPackagePrice = $variant['old_package_price'] ?? null;
|
||||
$oldUnitPrice = null;
|
||||
|
||||
if ($showUnitPrice && $oldPackagePrice !== null && $packageQuantity > 0) {
|
||||
$oldUnitPrice = (float) $oldPackagePrice / $packageQuantity;
|
||||
}
|
||||
|
||||
$tierBase = $showUnitPrice && $unitPrice !== null ? (float) $unitPrice : (float) ($packagePrice ?? 0);
|
||||
$tierUnit = $showUnitPrice ? $unitLabel : 'фасовку';
|
||||
?>
|
||||
<div
|
||||
class="variant-row"
|
||||
data-variant-id="<?= e((string) ($variant['id'] ?? '')) ?>"
|
||||
data-variant-name="<?= e((string) ($variant['name'] ?? '')) ?>"
|
||||
data-unit="<?= e(unit_label((string) $variant['unit'])) ?>"
|
||||
data-variant-name="<?= e($variantName) ?>"
|
||||
data-unit="<?= e($unitLabel) ?>"
|
||||
data-package-quantity="<?= e((string) ($variant['package_quantity'] ?? '')) ?>"
|
||||
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 ($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; ?>
|
||||
<span data-dynamic-package-price data-base-package-price="<?= e((string) $variant['package_price']) ?>"><?= e(money_label($variant['package_price'])) ?></span>
|
||||
</b>
|
||||
<div class="variant-row-head">
|
||||
<span>Фасовка</span>
|
||||
<strong><?= e($variantName) ?></strong>
|
||||
</div>
|
||||
|
||||
<div class="variant-row-prices">
|
||||
<span class="price-line<?= $showUnitPrice ? '' : ' is-price-placeholder' ?>" data-unit-price-row aria-hidden="<?= $showUnitPrice ? 'false' : 'true' ?>">
|
||||
<span class="price-unit-label">Цена за <span data-unit-label><?= e($unitLabel) ?></span>:</span>
|
||||
<span class="price-unit-values">
|
||||
<span class="old-price" data-old-unit-price-display<?= $oldUnitPrice === null ? ' hidden' : '' ?>><?= e($oldUnitPrice === null ? '' : money_label($oldUnitPrice)) ?></span>
|
||||
<b data-price-unit data-dynamic-unit-price data-base-unit-price="<?= e((string) $unitPrice) ?>"><?= e($unitPrice === null ? '' : money_label($unitPrice)) ?></b>
|
||||
<button class="price-tier-trigger" type="button" aria-label="Показать варианты цены за наличный расчет">?</button>
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<strong class="package-price-line">
|
||||
<span class="package-price-label">За фасовку <span data-package-label-display><?= e($variantName) ?></span>:</span>
|
||||
<span class="package-price-values">
|
||||
<span class="old-price" data-old-package-price-display<?= $oldPackagePrice === null ? ' hidden' : '' ?>><?= e($oldPackagePrice === null ? '' : money_label($oldPackagePrice)) ?></span>
|
||||
<span data-package-price data-dynamic-package-price data-base-package-price="<?= e((string) $packagePrice) ?>"><?= e($packagePrice === null ? '' : money_label($packagePrice)) ?></span>
|
||||
<button class="price-tier-trigger" data-package-tier-trigger type="button" aria-label="Показать варианты цены за наличный расчет"<?= $showUnitPrice ? ' hidden' : '' ?>>?</button>
|
||||
</span>
|
||||
</strong>
|
||||
|
||||
<span class="package-price-note<?= $showUnitPrice ? '' : ' is-price-placeholder' ?>" data-package-price-note aria-hidden="<?= $showUnitPrice ? 'false' : 'true' ?>">Цена за <span data-unit-label-note><?= e($unitLabel) ?></span> x <span data-package-label-note><?= e($variantName) ?></span></span>
|
||||
|
||||
<div class="price-tier-popover" role="tooltip">
|
||||
<strong>Варианты цены за <span data-tier-unit-label><?= e($tierUnit) ?></span> при наличном расчете:</strong>
|
||||
<dl>
|
||||
<div><dt>Базовая цена</dt><dd data-tier-base><?= e(money_label($tierBase)) ?></dd></div>
|
||||
<div><dt>При заказе от 20 000р.</dt><dd data-tier-cash-20><?= e(money_label(floor($tierBase * 0.95))) ?></dd></div>
|
||||
<div><dt>При заказе от 50 000р.</dt><dd data-tier-cash-50><?= e(money_label(floor($tierBase * 0.93))) ?></dd></div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="product-card-actions">
|
||||
<div class="quantity-stepper" data-quantity-control aria-label="Количество фасовок">
|
||||
<button type="button" data-quantity-minus aria-label="Уменьшить количество">-</button>
|
||||
@@ -103,6 +159,8 @@ $showUnitPriceForVariant = static function (array $variant) use ($product): bool
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<p class="product-detail-preorder">На сайте оформляется предзаказ. Мы перезвоним, подтвердим наличие, фактический вес и удобное получение.</p>
|
||||
</article>
|
||||
|
||||
<?php if (!empty($product['description'])): ?>
|
||||
|
||||
Reference in New Issue
Block a user