158 lines
9.4 KiB
PHTML
158 lines
9.4 KiB
PHTML
<?php
|
|
|
|
/**
|
|
* @var \Esun\Homepage\Block\HotSaleFilament $block
|
|
* @var \Magento\Framework\Escaper $escaper
|
|
*/
|
|
|
|
$products = $block->getProducts();
|
|
if (!$products) {
|
|
return;
|
|
}
|
|
|
|
$pages = [array_slice($products, 0, 7)];
|
|
$remainingProducts = array_slice($products, 7);
|
|
foreach (array_chunk($remainingProducts, 8) as $pageProducts) {
|
|
$pages[] = $pageProducts;
|
|
}
|
|
$hasPagination = count($pages) > 1;
|
|
$exploreAllUrl = $block->getExploreAllUrl();
|
|
?>
|
|
<?php if (count($products) > 0) : ?>
|
|
<section class="esun-hot-sale" aria-labelledby="esun-hot-sale-title">
|
|
<div class="esun-hot-sale__heading">
|
|
<h2 class="typo-section-title" id="esun-hot-sale-title"><?= $escaper->escapeHtml(__('Hot Sale Filaments')) ?></h2>
|
|
<div class="esun-hot-sale__heading-row">
|
|
<?php if ($block->getSubtitle()): ?>
|
|
<p class="typo-product-title"><?= $escaper->escapeHtml($block->getSubtitle()) ?></p>
|
|
<?php endif; ?>
|
|
<a class="esun-hot-sale__explore"
|
|
href="<?= $exploreAllUrl ? $escaper->escapeUrl($exploreAllUrl) : '#' ?>"
|
|
<?= $exploreAllUrl ? '' : 'role="link" aria-disabled="true" onclick="return false;"' ?>>
|
|
<?= $escaper->escapeHtml(__('Explore All')) ?>
|
|
<span aria-hidden="true">></span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="esun-hot-sale__slider swiper-container"
|
|
data-role="esun-hot-sale-slider"
|
|
data-has-pagination="<?= $hasPagination ? 'true' : 'false' ?>">
|
|
<div class="swiper-wrapper">
|
|
<?php foreach ($pages as $pageIndex => $pageProducts): ?>
|
|
<div class="esun-hot-sale__page swiper-slide">
|
|
<ol class="esun-hot-sale__grid">
|
|
<?php foreach ($pageProducts as $productIndex => $product): ?>
|
|
<?php
|
|
$isFeatured = $pageIndex === 0 && $productIndex === 0;
|
|
$colorSwatches = $block->getColorSwatches($product);
|
|
$visibleSwatches = array_slice($colorSwatches, 0, 11);
|
|
$remainingSwatches = max(0, count($colorSwatches) - count($visibleSwatches));
|
|
$shortDescription = $isFeatured ? $block->getShortDescription($product) : '';
|
|
?>
|
|
<li class="esun-hot-sale__item<?= $isFeatured ? ' esun-hot-sale__item--featured' : '' ?>">
|
|
<article class="esun-hot-sale__card" data-role="esun-product-card">
|
|
<a class="esun-hot-sale__image"
|
|
href="<?= $escaper->escapeUrl($product->getProductUrl()) ?>"
|
|
data-role="esun-product-image"
|
|
aria-label="<?= $escaper->escapeHtmlAttr($product->getName()) ?>">
|
|
<?= /* @noEscape */ $block->getImage(
|
|
$product,
|
|
$isFeatured ? 'product_page_image_large' : 'category_page_grid'
|
|
)->toHtml() ?>
|
|
</a>
|
|
|
|
<div class="esun-hot-sale__details">
|
|
<h3>
|
|
<a href="<?= $escaper->escapeUrl($product->getProductUrl()) ?>">
|
|
<?= $escaper->escapeHtml($product->getName()) ?>
|
|
</a>
|
|
</h3>
|
|
|
|
<?php if ($shortDescription): ?>
|
|
<p class="esun-hot-sale__description">
|
|
<?= $escaper->escapeHtml($shortDescription) ?>
|
|
</p>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($colorSwatches): ?>
|
|
<div class="esun-hot-sale__swatches"
|
|
data-role="esun-product-swatches"
|
|
aria-label="<?= $escaper->escapeHtmlAttr(__('Available Colors')) ?>">
|
|
<?php foreach ($visibleSwatches as $swatch): ?>
|
|
<span class="esun-hot-sale__swatch"
|
|
data-child-image="<?= $escaper->escapeUrl($isFeatured ? $swatch['product_image_large'] : $swatch['product_image']) ?>"
|
|
title="<?= $escaper->escapeHtmlAttr($swatch['label']) ?>"
|
|
aria-label="<?= $escaper->escapeHtmlAttr($swatch['label']) ?>">
|
|
<?php if ($swatch['image']): ?>
|
|
<img src="<?= $escaper->escapeUrl($swatch['image']) ?>"
|
|
alt="<?= $escaper->escapeHtmlAttr($swatch['label']) ?>">
|
|
<?php elseif ($swatch['value']): ?>
|
|
<span style="background-color: <?= $escaper->escapeHtmlAttr($swatch['value']) ?>"></span>
|
|
<?php else: ?>
|
|
<span></span>
|
|
<?php endif; ?>
|
|
</span>
|
|
<?php endforeach; ?>
|
|
<?php if ($remainingSwatches > 0): ?>
|
|
<span class="esun-hot-sale__swatch-more">
|
|
+<?= (int) $remainingSwatches ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="esun-hot-sale__footer">
|
|
<div class="esun-hot-sale__price">
|
|
<span class="esun-hot-sale__final-price">
|
|
<?= $escaper->escapeHtml($block->getFormattedFinalPrice($product)) ?>
|
|
</span>
|
|
<?php if ($block->hasRegularPrice($product)): ?>
|
|
<span class="esun-hot-sale__regular-price">
|
|
<?= $escaper->escapeHtml($block->getFormattedRegularPrice($product)) ?>
|
|
</span>
|
|
<?php endif; ?>
|
|
</div>
|
|
<a class="esun-hot-sale__cart"
|
|
href="<?= $escaper->escapeUrl($product->getProductUrl()) ?>"
|
|
title="<?= $escaper->escapeHtmlAttr(__('View Product')) ?>">
|
|
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
<path d="M3 4h2l2.2 10.2a2 2 0 0 0 2 1.6h7.7a2 2 0 0 0 2-1.6L20 8H7M10 20a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm8 0a1 1 0 1 1-2 0 1 1 0 0 1 2 0Z" />
|
|
</svg>
|
|
<span class="esun-hot-sale__visually-hidden">
|
|
<?= $escaper->escapeHtml(__('View Product')) ?>
|
|
</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
</li>
|
|
<?php endforeach; ?>
|
|
</ol>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php if ($hasPagination): ?>
|
|
<div class="esun-hot-sale__pagination swiper-pagination"></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</section>
|
|
|
|
<?php if ($hasPagination): ?>
|
|
<script type="text/x-magento-init">
|
|
{
|
|
"[data-role=esun-hot-sale-slider]": {
|
|
"Esun_Homepage/js/hot-sale-filament": {}
|
|
}
|
|
}
|
|
</script>
|
|
<?php endif; ?>
|
|
<script type="text/x-magento-init">
|
|
{
|
|
".esun-hot-sale": {
|
|
"Esun_Homepage/js/product-swatch-image": {}
|
|
}
|
|
}
|
|
</script>
|
|
<?php endif; ?>
|