Files
vinoteca/local/components/jinove/cart/templates/.default/template.php
T

140 lines
14 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
use Bitrix\Main\Localization\Loc;
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die();
}
Loc::loadMessages(__FILE__);
$cart = $arResult["CART"];
$hasItems = !empty($cart["items"]);
$appliedCoupons = array_values(array_filter($cart["coupons"], static fn(array $coupon): bool => $coupon["applied"]));
$text = static fn(string $key): string => htmlspecialcharsbx((string)Loc::getMessage($key));
$title = htmlspecialcharsbx($arResult["TITLE"]);
?>
<section class="vino-razdel-hero">
<div class="vino-wrap">
<?php \Jinove\Vinoteca\Breadcrumbs::show(array(array($arResult["TITLE"]))); ?>
<h1 class="vino-razdel-hero__title"><?= $title ?></h1>
</div>
</section>
<section class="vino-cart" data-cart data-max="<?= (int)$arResult["MAX_QUANTITY"] ?>" data-text-coupon-error="<?= $text("VINO_CART_COUPON_ERROR") ?>" data-text-coupon-empty="<?= $text("VINO_CART_COUPON_EMPTY") ?>" data-text-coupon-remove="<?= $text("VINO_CART_COUPON_REMOVE") ?>" data-text-fail="<?= $text("VINO_CART_FAIL") ?>">
<?php if ($arResult["SHARE_REQUESTED"]): $shared = $arResult["SHARED"]; ?>
<div class="vino-cart__shared" data-cart-shared="<?= htmlspecialcharsbx($shared["code"] ?? "") ?>" data-cart-url="<?= htmlspecialcharsbx($arResult["CART_URL"]) ?>" aria-labelledby="vino-cart-shared-title" role="region">
<h2 class="vino-cart__shared-title" id="vino-cart-shared-title"><?= $text("VINO_CART_SHARED_TITLE") ?></h2>
<?php if (!empty($shared["items"])): ?>
<p class="vino-cart__shared-hint"><?= $text("VINO_CART_SHARED_HINT") ?></p>
<ul class="vino-cart__shared-list">
<?php foreach ($shared["items"] as $item): ?>
<li class="vino-cart__shared-item">
<span class="vino-cart__shared-pic">
<?php if ($item["image"] !== ""): ?><img class="vino-cart__img" src="<?= htmlspecialcharsbx($item["image"]) ?>" width="72" height="90" alt="" loading="lazy" decoding="async"><?php else: ?><span class="vino-photo-stub vino-photo-stub--sm"><span class="vino-photo-stub__brand"><?= htmlspecialcharsbx($item["brand"]) ?></span></span><?php endif; ?>
</span>
<a class="vino-cart__shared-name" href="<?= htmlspecialcharsbx($item["url"]) ?>"><?= htmlspecialcharsbx($item["name"]) ?></a>
<span class="vino-cart__shared-qty">× <?= (int)$item["quantity"] ?></span>
<span class="vino-cart__shared-sum"><?= htmlspecialcharsbx($item["sum"]) ?></span>
</li>
<?php endforeach; ?>
</ul>
<div class="vino-cart__shared-foot">
<p class="vino-cart__shared-total"><?= $text("VINO_CART_SHARED_TOTAL") ?> <span class="vino-cart__shared-total-value"><?= htmlspecialcharsbx($shared["total"]) ?></span></p>
<button type="button" class="vino-btn vino-btn--sm vino-cart__shared-button" data-cart-shared-add><?= $text("VINO_CART_SHARED_ADD") ?></button>
<a class="vino-btn vino-btn--sm vino-btn--outline vino-cart__shared-button" href="<?= htmlspecialcharsbx($arResult["CART_URL"]) ?>"><?= $text("VINO_CART_SHARED_HIDE") ?></a>
</div>
<?php else: ?>
<p class="vino-cart__shared-hint"><?= $text("VINO_CART_SHARED_EMPTY") ?></p>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="vino-cart__layout" data-cart-layout<?= $hasItems ? "" : " hidden" ?>>
<div class="vino-cart__main">
<div class="vino-cart__toolbar">
<p class="vino-cart__count" data-cart-count-text><?= htmlspecialcharsbx($cart["summary"]) ?></p>
<div class="vino-cart__actions" data-cart-actions>
<button type="button" class="vino-cart__link vino-cart__share" data-cart-share data-title="<?= $text("VINO_CART_SHARE_TITLE") ?>">
<span class="vino-cart__share-label vino-cart__share-label--idle" data-cart-share-label><?= $text("VINO_CART_SHARE") ?></span>
<span class="vino-cart__share-label vino-cart__share-label--done" data-cart-share-done aria-hidden="true"><?= $text("VINO_CART_SHARE_COPIED") ?></span>
</button>
<button type="button" class="vino-cart__link" data-cart-clear><?= $text("VINO_CART_CLEAR") ?></button>
</div>
<div class="vino-cart__confirm" data-cart-confirm hidden>
<p class="vino-cart__confirm-text"><?= $text("VINO_CART_CLEAR_CONFIRM") ?></p>
<button type="button" class="vino-btn vino-btn--sm" data-cart-clear-yes><?= $text("VINO_CART_YES") ?></button>
<button type="button" class="vino-btn vino-btn--sm vino-btn--outline" data-cart-clear-no><?= $text("VINO_CART_NO") ?></button>
</div>
<label class="vino-cart__share-fallback" data-cart-share-fallback hidden>
<span class="vino-cart__label"><?= $text("VINO_CART_SHARE_LINK") ?></span>
<input class="vino-inp vino-cart__share-input" type="text" readonly data-cart-share-input>
</label>
</div>
<p class="vino-sr-only" role="status" data-cart-share-status></p>
<p class="vino-cart__fail" role="alert" data-cart-fail hidden></p>
<ul class="vino-cart__list" aria-label="<?= $text("VINO_CART_LIST") ?>">
<?php foreach ($cart["items"] as $index => $item): ?>
<li class="vino-cart__item<?= $item["available"] ? "" : " vino-cart__item--unavailable" ?>" data-cart-item="<?= (int)$item["id"] ?>">
<<?= $item["url"] !== "" ? 'a href="' . htmlspecialcharsbx($item["url"]) . '" tabindex="-1" aria-hidden="true"' : 'span' ?> class="vino-cart__pic">
<?php if ($item["image"] !== ""): ?>
<img class="vino-cart__img" src="<?= htmlspecialcharsbx($item["image"]) ?>" width="80" height="100" alt="" <?= $index < 2 ? 'fetchpriority="high"' : 'loading="lazy"' ?> decoding="async">
<?php else: ?>
<span class="vino-photo-stub vino-photo-stub--sm"><span class="vino-photo-stub__brand"><?= htmlspecialcharsbx($item["brand"]) ?></span></span>
<?php endif; ?>
</<?= $item["url"] !== "" ? "a" : "span" ?>>
<div class="vino-cart__info">
<<?= $item["url"] !== "" ? 'a href="' . htmlspecialcharsbx($item["url"]) . '"' : 'span' ?> class="vino-cart__name"><?= htmlspecialcharsbx($item["name"]) ?></<?= $item["url"] !== "" ? "a" : "span" ?>>
<?php if ($item["meta"] !== ""): ?><p class="vino-cart__meta"><?= htmlspecialcharsbx($item["meta"]) ?></p><?php endif; ?>
<p class="vino-cart__unit">
<span data-cart-price><?= htmlspecialcharsbx($item["price"]) ?></span> <?= $text("VINO_CART_PER_ITEM") ?>
<s class="vino-cart__old" data-cart-old<?= $item["basePrice"] === "" ? " hidden" : "" ?>><?= htmlspecialcharsbx($item["basePrice"]) ?></s>
</p>
<p class="vino-cart__warning" data-cart-unavailable<?= $item["available"] ? " hidden" : "" ?>><?= $text("VINO_CART_UNAVAILABLE") ?></p>
</div>
<div class="vino-cart__qty" role="group" aria-label="<?= htmlspecialcharsbx((string)Loc::getMessage("VINO_CART_QUANTITY", ["#NAME#" => $item["name"]])) ?>">
<button type="button" class="vino-cart__step" data-cart-step="-1" aria-label="<?= htmlspecialcharsbx((string)Loc::getMessage("VINO_CART_LESS", ["#NAME#" => $item["name"]])) ?>"><svg class="vino-cart__step-icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg></button>
<output class="vino-cart__value" data-cart-value aria-live="polite"><?= (int)$item["quantity"] ?></output>
<button type="button" class="vino-cart__step" data-cart-step="1" aria-label="<?= htmlspecialcharsbx((string)Loc::getMessage("VINO_CART_MORE", ["#NAME#" => $item["name"]])) ?>"><svg class="vino-cart__step-icon" viewBox="0 0 16 16" aria-hidden="true"><path d="M3 8h10M8 3v10" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg></button>
</div>
<p class="vino-cart__sum" data-cart-sum><?= htmlspecialcharsbx($item["sum"]) ?></p>
<button type="button" class="vino-cart__remove" data-cart-remove aria-label="<?= htmlspecialcharsbx((string)Loc::getMessage("VINO_CART_REMOVE", ["#NAME#" => $item["name"]])) ?>"><svg class="vino-cart__remove-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"></path></svg></button>
<div class="vino-cart__removed" data-cart-removed hidden>
<span class="vino-cart__removed-text"><?= $text("VINO_CART_REMOVED") ?></span>
<button type="button" class="vino-cart__restore" data-cart-restore aria-label="<?= htmlspecialcharsbx((string)Loc::getMessage("VINO_CART_RESTORE_NAME", ["#NAME#" => $item["name"]])) ?>"><?= $text("VINO_CART_RESTORE") ?></button>
</div>
</li>
<?php endforeach; ?>
</ul>
</div>
<aside class="vino-cart__summary" aria-labelledby="vino-cart-summary-title">
<h2 class="vino-cart__summary-title" id="vino-cart-summary-title"><?= $text("VINO_CART_SUMMARY") ?></h2>
<form class="vino-cart__coupon" method="post" novalidate data-cart-coupon>
<div class="vino-cart__coupon-head">
<label class="vino-cart__label" for="vino-cart-coupon"><?= $text("VINO_CART_COUPON") ?></label>
<button type="button" class="vino-cart__coupon-more" data-cart-coupon-more<?= $appliedCoupons ? "" : " hidden" ?>><?= $text("VINO_CART_COUPON_MORE") ?></button>
</div>
<div class="vino-cart__coupon-row"<?= $appliedCoupons ? " hidden" : "" ?>>
<input class="vino-inp vino-cart__coupon-input" id="vino-cart-coupon" type="text" name="code" maxlength="64" autocomplete="off" spellcheck="false" aria-invalid="false" aria-describedby="vino-cart-coupon-error">
<button class="vino-btn vino-btn--sm vino-btn--outline vino-cart__coupon-apply" type="submit"><?= $text("VINO_CART_COUPON_APPLY") ?></button>
</div>
<p class="vino-cart__coupon-hint" data-cart-coupon-hint<?= $appliedCoupons ? " hidden" : "" ?>><?php foreach (["VINO10" => "VINO_CART_COUPON_HINT_1", "RED5" => "VINO_CART_COUPON_HINT_2"] as $hintCode => $hintKey): ?><span class="vino-cart__coupon-hint-line"><button class="vino-cart__coupon-fill" type="button" data-cart-coupon-fill="<?= $hintCode ?>"><?= $hintCode ?></button>: <?= $text($hintKey) ?></span><?php endforeach; ?></p>
<ul class="vino-cart__coupons" data-cart-coupons>
<?php foreach ($cart["coupons"] as $coupon): if (!$coupon["applied"]) continue; ?>
<li class="vino-cart__coupon-item"><span class="vino-cart__coupon-code"><?= htmlspecialcharsbx($coupon["code"]) ?></span><button type="button" class="vino-cart__coupon-remove" data-cart-coupon-remove="<?= htmlspecialcharsbx($coupon["code"]) ?>" aria-label="<?= htmlspecialcharsbx((string)Loc::getMessage("VINO_CART_COUPON_REMOVE", ["#CODE#" => $coupon["code"]])) ?>"><svg class="vino-cart__remove-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6 6 18"></path></svg></button></li>
<?php endforeach; ?>
</ul>
<p class="vino-cart__error" id="vino-cart-coupon-error" role="alert" data-cart-coupon-error hidden></p>
</form>
<dl class="vino-cart__totals">
<div class="vino-cart__line"><dt class="vino-cart__term"><?= $text("VINO_CART_GOODS") ?></dt><dd class="vino-cart__value-line" data-cart-base><?= htmlspecialcharsbx($cart["base"]) ?></dd></div>
<div class="vino-cart__line vino-cart__line--discount<?= $cart["discount"] === "" ? " vino-cart__line--none" : "" ?>" data-cart-discount-line><dt class="vino-cart__term"><?= $text("VINO_CART_DISCOUNT") ?></dt><dd class="vino-cart__value-line" data-cart-discount><?= $cart["discount"] === "" ? "&mdash;" : htmlspecialcharsbx($cart["discount"]) ?></dd></div>
<div class="vino-cart__line vino-cart__line--total"><dt class="vino-cart__term"><?= $text("VINO_CART_TOTAL") ?></dt><dd class="vino-cart__value-line" data-cart-total><?= htmlspecialcharsbx($cart["total"]) ?></dd></div>
</dl>
<a class="vino-btn vino-cart__checkout" href="<?= htmlspecialcharsbx($arResult["CHECKOUT_URL"]) ?>" data-cart-checkout><?= $text("VINO_CART_CHECKOUT") ?></a>
</aside>
</div>
<div class="vino-cart__empty" data-cart-empty<?= $hasItems ? " hidden" : "" ?>>
<p class="vino-cart__empty-title" tabindex="-1" data-cart-empty-title><?= $text("VINO_CART_EMPTY") ?></p>
<p class="vino-cart__empty-text"><?= $text("VINO_CART_EMPTY_HINT") ?></p>
<a class="vino-btn" href="<?= htmlspecialcharsbx($arResult["CATALOG_URL"]) ?>"><?= $text("VINO_CART_TO_CATALOG") ?></a>
</div>
</section>