Vinoteca: модуль, шаблон и компоненты интернет-магазина вина на 1С-Битрикс
This commit is contained in:
commit
bb7d8af290
469 files changed
+26426
No files matched your search
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
$MESS["VINO_CART_CLEAR"] = "Empty cart";
|
||||
$MESS["VINO_CART_CLEAR_CONFIRM"] = "Remove all items from the cart?";
|
||||
$MESS["VINO_CART_YES"] = "Yes, empty it";
|
||||
$MESS["VINO_CART_NO"] = "Cancel";
|
||||
$MESS["VINO_CART_LIST"] = "Items in the cart";
|
||||
$MESS["VINO_CART_PER_ITEM"] = "each";
|
||||
$MESS["VINO_CART_QUANTITY"] = "Quantity: #NAME#";
|
||||
$MESS["VINO_CART_LESS"] = "Decrease quantity: #NAME#";
|
||||
$MESS["VINO_CART_MORE"] = "Increase quantity: #NAME#";
|
||||
$MESS["VINO_CART_REMOVE"] = "Remove: #NAME#";
|
||||
$MESS["VINO_CART_REMOVED"] = "Item removed from the cart";
|
||||
$MESS["VINO_CART_RESTORE"] = "Undo";
|
||||
$MESS["VINO_CART_RESTORE_NAME"] = "Undo: #NAME#";
|
||||
$MESS["VINO_CART_UNAVAILABLE"] = "Out of stock, not included in the total";
|
||||
$MESS["VINO_CART_SUMMARY"] = "Order summary";
|
||||
$MESS["VINO_CART_COUPON"] = "Promo code";
|
||||
$MESS["VINO_CART_COUPON_MORE"] = "Add another";
|
||||
$MESS["VINO_CART_COUPON_APPLY"] = "Apply";
|
||||
$MESS["VINO_CART_COUPON_ERROR"] = "Promo code not found or no longer valid.";
|
||||
$MESS["VINO_CART_COUPON_EMPTY"] = "Enter a promo code.";
|
||||
$MESS["VINO_CART_COUPON_REMOVE"] = "Remove promo code #CODE#";
|
||||
$MESS["VINO_CART_GOODS"] = "Items";
|
||||
$MESS["VINO_CART_DISCOUNT"] = "Discount";
|
||||
$MESS["VINO_CART_TOTAL"] = "Total";
|
||||
$MESS["VINO_CART_CHECKOUT"] = "Proceed to checkout";
|
||||
$MESS["VINO_CART_EMPTY"] = "The cart is empty.";
|
||||
$MESS["VINO_CART_EMPTY_HINT"] = "Wines can be added to the cart from the catalogue and wine pages.";
|
||||
$MESS["VINO_CART_TO_CATALOG"] = "Browse the catalogue";
|
||||
$MESS["VINO_CART_SHARE"] = "Share cart";
|
||||
$MESS["VINO_CART_SHARE_COPIED"] = "Link copied";
|
||||
$MESS["VINO_CART_SHARE_LINK"] = "Cart link";
|
||||
$MESS["VINO_CART_SHARE_TITLE"] = "Vinoteca cart";
|
||||
$MESS["VINO_CART_SHARED_TITLE"] = "Shared wine selection";
|
||||
$MESS["VINO_CART_SHARED_HINT"] = "Wines from the link are added to whatever is already in the cart.";
|
||||
$MESS["VINO_CART_SHARED_TOTAL"] = "Total value";
|
||||
$MESS["VINO_CART_SHARED_ADD"] = "Add to cart";
|
||||
$MESS["VINO_CART_SHARED_HIDE"] = "Don't add";
|
||||
$MESS["VINO_CART_SHARED_EMPTY"] = "The wines from this link are currently unavailable.";
|
||||
$MESS["VINO_CART_FAIL"] = "The cart could not be updated. Please try again.";
|
||||
$MESS["VINO_CART_COUPON_HINT_1"] = "10% off red wines";
|
||||
$MESS["VINO_CART_COUPON_HINT_2"] = "5% off red wines";
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
$MESS["VINO_CART_CLEAR"] = "Wyczyść koszyk";
|
||||
$MESS["VINO_CART_CLEAR_CONFIRM"] = "Usunąć wszystkie produkty z koszyka?";
|
||||
$MESS["VINO_CART_YES"] = "Tak, wyczyść";
|
||||
$MESS["VINO_CART_NO"] = "Anuluj";
|
||||
$MESS["VINO_CART_LIST"] = "Produkty w koszyku";
|
||||
$MESS["VINO_CART_PER_ITEM"] = "za szt.";
|
||||
$MESS["VINO_CART_QUANTITY"] = "Ilość: #NAME#";
|
||||
$MESS["VINO_CART_LESS"] = "Zmniejsz ilość: #NAME#";
|
||||
$MESS["VINO_CART_MORE"] = "Zwiększ ilość: #NAME#";
|
||||
$MESS["VINO_CART_REMOVE"] = "Usuń: #NAME#";
|
||||
$MESS["VINO_CART_REMOVED"] = "Produkt usunięty z koszyka";
|
||||
$MESS["VINO_CART_RESTORE"] = "Cofnij";
|
||||
$MESS["VINO_CART_RESTORE_NAME"] = "Cofnij: #NAME#";
|
||||
$MESS["VINO_CART_UNAVAILABLE"] = "Brak w magazynie, nie wliczono do sumy";
|
||||
$MESS["VINO_CART_SUMMARY"] = "Podsumowanie zamówienia";
|
||||
$MESS["VINO_CART_COUPON"] = "Kod rabatowy";
|
||||
$MESS["VINO_CART_COUPON_MORE"] = "Dodaj kolejny";
|
||||
$MESS["VINO_CART_COUPON_APPLY"] = "Zastosuj";
|
||||
$MESS["VINO_CART_COUPON_ERROR"] = "Kod nie istnieje lub stracił ważność.";
|
||||
$MESS["VINO_CART_COUPON_EMPTY"] = "Wpisz kod rabatowy.";
|
||||
$MESS["VINO_CART_COUPON_REMOVE"] = "Usuń kod #CODE#";
|
||||
$MESS["VINO_CART_GOODS"] = "Produkty";
|
||||
$MESS["VINO_CART_DISCOUNT"] = "Rabat";
|
||||
$MESS["VINO_CART_TOTAL"] = "Razem";
|
||||
$MESS["VINO_CART_CHECKOUT"] = "Przejdź do zamówienia";
|
||||
$MESS["VINO_CART_EMPTY"] = "Koszyk jest pusty.";
|
||||
$MESS["VINO_CART_EMPTY_HINT"] = "Wina można dodać do koszyka z katalogu i stron win.";
|
||||
$MESS["VINO_CART_TO_CATALOG"] = "Przejdź do katalogu";
|
||||
$MESS["VINO_CART_SHARE"] = "Udostępnij koszyk";
|
||||
$MESS["VINO_CART_SHARE_COPIED"] = "Link skopiowany";
|
||||
$MESS["VINO_CART_SHARE_LINK"] = "Link do koszyka";
|
||||
$MESS["VINO_CART_SHARE_TITLE"] = "Koszyk Vinoteca";
|
||||
$MESS["VINO_CART_SHARED_TITLE"] = "Zestaw win z linku";
|
||||
$MESS["VINO_CART_SHARED_HINT"] = "Wina z linku zostaną dodane do tych, które już są w koszyku.";
|
||||
$MESS["VINO_CART_SHARED_TOTAL"] = "Wartość";
|
||||
$MESS["VINO_CART_SHARED_ADD"] = "Dodaj do koszyka";
|
||||
$MESS["VINO_CART_SHARED_HIDE"] = "Nie dodawaj";
|
||||
$MESS["VINO_CART_SHARED_EMPTY"] = "Wina z tego linku są obecnie niedostępne.";
|
||||
$MESS["VINO_CART_FAIL"] = "Nie udało się zaktualizować koszyka. Spróbuj ponownie.";
|
||||
$MESS["VINO_CART_COUPON_HINT_1"] = "10% zniżki na czerwone wina";
|
||||
$MESS["VINO_CART_COUPON_HINT_2"] = "5% zniżki na czerwone wina";
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
$MESS["VINO_CART_CLEAR"] = "Очистить корзину";
|
||||
$MESS["VINO_CART_CLEAR_CONFIRM"] = "Удалить все товары из корзины?";
|
||||
$MESS["VINO_CART_YES"] = "Да, очистить";
|
||||
$MESS["VINO_CART_NO"] = "Отмена";
|
||||
$MESS["VINO_CART_LIST"] = "Товары в корзине";
|
||||
$MESS["VINO_CART_PER_ITEM"] = "за шт.";
|
||||
$MESS["VINO_CART_QUANTITY"] = "Количество: #NAME#";
|
||||
$MESS["VINO_CART_LESS"] = "Уменьшить количество: #NAME#";
|
||||
$MESS["VINO_CART_MORE"] = "Увеличить количество: #NAME#";
|
||||
$MESS["VINO_CART_REMOVE"] = "Удалить: #NAME#";
|
||||
$MESS["VINO_CART_REMOVED"] = "Товар удалён из корзины";
|
||||
$MESS["VINO_CART_RESTORE"] = "Вернуть";
|
||||
$MESS["VINO_CART_RESTORE_NAME"] = "Вернуть: #NAME#";
|
||||
$MESS["VINO_CART_UNAVAILABLE"] = "Нет в наличии, в сумму не входит";
|
||||
$MESS["VINO_CART_SUMMARY"] = "Итог заказа";
|
||||
$MESS["VINO_CART_COUPON"] = "Промокод";
|
||||
$MESS["VINO_CART_COUPON_MORE"] = "Добавить ещё";
|
||||
$MESS["VINO_CART_COUPON_APPLY"] = "Применить";
|
||||
$MESS["VINO_CART_COUPON_ERROR"] = "Промокод не найден или не действует.";
|
||||
$MESS["VINO_CART_COUPON_EMPTY"] = "Введите промокод.";
|
||||
$MESS["VINO_CART_COUPON_REMOVE"] = "Убрать промокод #CODE#";
|
||||
$MESS["VINO_CART_GOODS"] = "Товары";
|
||||
$MESS["VINO_CART_DISCOUNT"] = "Скидка";
|
||||
$MESS["VINO_CART_TOTAL"] = "Итого";
|
||||
$MESS["VINO_CART_CHECKOUT"] = "Перейти к оформлению";
|
||||
$MESS["VINO_CART_EMPTY"] = "В корзине пока ничего нет.";
|
||||
$MESS["VINO_CART_EMPTY_HINT"] = "Вина добавляются в корзину из каталога и карточек.";
|
||||
$MESS["VINO_CART_TO_CATALOG"] = "Перейти в каталог";
|
||||
$MESS["VINO_CART_SHARE"] = "Поделиться корзиной";
|
||||
$MESS["VINO_CART_SHARE_COPIED"] = "Ссылка скопирована";
|
||||
$MESS["VINO_CART_SHARE_LINK"] = "Ссылка на корзину";
|
||||
$MESS["VINO_CART_SHARE_TITLE"] = "Корзина Vinoteca";
|
||||
$MESS["VINO_CART_SHARED_TITLE"] = "Набор вин по ссылке";
|
||||
$MESS["VINO_CART_SHARED_HINT"] = "Вина из ссылки добавляются к тем, что уже лежат в корзине.";
|
||||
$MESS["VINO_CART_SHARED_TOTAL"] = "На сумму";
|
||||
$MESS["VINO_CART_SHARED_ADD"] = "Добавить в корзину";
|
||||
$MESS["VINO_CART_SHARED_HIDE"] = "Не добавлять";
|
||||
$MESS["VINO_CART_SHARED_EMPTY"] = "Вин из этой ссылки сейчас нет в продаже.";
|
||||
$MESS["VINO_CART_FAIL"] = "Не получилось обновить корзину. Попробуйте ещё раз.";
|
||||
$MESS["VINO_CART_COUPON_HINT_1"] = "скидка 10% на красные вина";
|
||||
$MESS["VINO_CART_COUPON_HINT_2"] = "скидка 5% на красные вина";
|
||||
@@ -0,0 +1,387 @@
|
||||
(function () {
|
||||
var root = document.querySelector('[data-cart]');
|
||||
if (!root || !window.BX || !BX.ajax || !BX.ajax.runAction) return;
|
||||
var max = parseInt(root.getAttribute('data-max'), 10);
|
||||
var layout = root.querySelector('[data-cart-layout]');
|
||||
var empty = root.querySelector('[data-cart-empty]');
|
||||
var emptyTitle = root.querySelector('[data-cart-empty-title]');
|
||||
var fail = root.querySelector('[data-cart-fail]');
|
||||
var confirmBox = root.querySelector('[data-cart-confirm]');
|
||||
var clearButton = root.querySelector('[data-cart-clear]');
|
||||
var actions = root.querySelector('[data-cart-actions]');
|
||||
var shareButton = root.querySelector('[data-cart-share]');
|
||||
var shareStatus = root.querySelector('[data-cart-share-status]');
|
||||
var shareFallback = root.querySelector('[data-cart-share-fallback]');
|
||||
var couponForm = root.querySelector('[data-cart-coupon]');
|
||||
var couponInput = couponForm.elements.code;
|
||||
var couponError = root.querySelector('[data-cart-coupon-error]');
|
||||
var couponList = root.querySelector('[data-cart-coupons]');
|
||||
var couponRowBox = couponForm.querySelector('.vino-cart__coupon-row');
|
||||
var couponMore = couponForm.querySelector('[data-cart-coupon-more]');
|
||||
var couponHint = couponForm.querySelector('[data-cart-coupon-hint]');
|
||||
var couponExpanded = false;
|
||||
var timers = {};
|
||||
var queue = Promise.resolve();
|
||||
var version = 0;
|
||||
var inflight = 0;
|
||||
var clearing = false;
|
||||
var shareTimer = 0;
|
||||
|
||||
function noop() {}
|
||||
|
||||
function text(name) {
|
||||
return root.getAttribute('data-text-' + name) || '';
|
||||
}
|
||||
|
||||
function item(id) {
|
||||
return root.querySelector('[data-cart-item="' + id + '"]');
|
||||
}
|
||||
|
||||
function field(li, name) {
|
||||
return li.querySelector('[data-cart-' + name + ']');
|
||||
}
|
||||
|
||||
function showFail(on) {
|
||||
fail.textContent = on ? text('fail') : '';
|
||||
fail.hidden = !on;
|
||||
}
|
||||
|
||||
function couponRow(code) {
|
||||
var li = document.createElement('li');
|
||||
li.className = 'vino-cart__coupon-item';
|
||||
var span = document.createElement('span');
|
||||
span.className = 'vino-cart__coupon-code';
|
||||
span.textContent = code;
|
||||
var button = document.createElement('button');
|
||||
button.type = 'button';
|
||||
button.className = 'vino-cart__coupon-remove';
|
||||
button.setAttribute('data-cart-coupon-remove', code);
|
||||
button.setAttribute('aria-label', text('coupon-remove').replace('#CODE#', code));
|
||||
button.innerHTML = '<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>';
|
||||
li.appendChild(span);
|
||||
li.appendChild(button);
|
||||
return li;
|
||||
}
|
||||
|
||||
function lock(li, on) {
|
||||
var removed = field(li, 'removed');
|
||||
Array.prototype.forEach.call(li.children, function (child) {
|
||||
if (child !== removed) child.inert = on;
|
||||
});
|
||||
li.classList.toggle('vino-cart__item--removed', on);
|
||||
removed.hidden = !on;
|
||||
}
|
||||
|
||||
function patch(cart) {
|
||||
var seen = {};
|
||||
cart.items.forEach(function (data) {
|
||||
var li = item(data.id);
|
||||
if (!li) return;
|
||||
seen[data.id] = true;
|
||||
if (!timers[data.id]) {
|
||||
if (li.classList.contains('vino-cart__item--removed')) lock(li, false);
|
||||
field(li, 'value').textContent = data.quantity;
|
||||
}
|
||||
li.classList.toggle('vino-cart__item--unavailable', !data.available);
|
||||
field(li, 'unavailable').hidden = data.available;
|
||||
field(li, 'price').textContent = data.price;
|
||||
var old = field(li, 'old');
|
||||
old.textContent = data.basePrice;
|
||||
old.hidden = !data.basePrice;
|
||||
field(li, 'sum').textContent = data.sum;
|
||||
});
|
||||
root.querySelectorAll('[data-cart-item]').forEach(function (li) {
|
||||
var id = li.getAttribute('data-cart-item');
|
||||
var removed = li.classList.contains('vino-cart__item--removed');
|
||||
if (!seen[id] && !timers[id] && (clearing || !removed)) li.remove();
|
||||
});
|
||||
root.querySelector('[data-cart-count-text]').textContent = cart.summary;
|
||||
root.querySelector('[data-cart-base]').textContent = cart.base;
|
||||
root.querySelector('[data-cart-total]').textContent = cart.total;
|
||||
root.querySelector('[data-cart-discount]').textContent = cart.discount || '—';
|
||||
root.querySelector('[data-cart-discount-line]').classList.toggle('vino-cart__line--none', !cart.discount);
|
||||
couponList.textContent = '';
|
||||
var applied = 0;
|
||||
cart.coupons.forEach(function (coupon) {
|
||||
if (!coupon.applied) return;
|
||||
couponList.appendChild(couponRow(coupon.code));
|
||||
applied++;
|
||||
});
|
||||
if (!applied) couponExpanded = false;
|
||||
couponRowBox.hidden = applied > 0 && !couponExpanded;
|
||||
couponHint.hidden = couponRowBox.hidden;
|
||||
couponMore.hidden = applied === 0 || couponExpanded;
|
||||
var left = root.querySelectorAll('[data-cart-item]').length;
|
||||
layout.hidden = !left;
|
||||
empty.hidden = !!left;
|
||||
}
|
||||
|
||||
function apply(res, sent) {
|
||||
var data = res && res.data;
|
||||
if (!data || !data.cart || sent !== version) return;
|
||||
if (data.state) document.dispatchEvent(new CustomEvent('vino:basket', { detail: data.state }));
|
||||
showFail(!data.ok);
|
||||
patch(data.cart);
|
||||
}
|
||||
|
||||
function recover(sent) {
|
||||
if (sent !== version) return;
|
||||
showFail(true);
|
||||
BX.ajax.runAction('jinove:vinoteca.basket.cart', { method: 'GET' }).then(function (res) {
|
||||
if (sent === version && res.data && res.data.cart) {
|
||||
if (res.data.state) document.dispatchEvent(new CustomEvent('vino:basket', { detail: res.data.state }));
|
||||
patch(res.data.cart);
|
||||
}
|
||||
}, noop);
|
||||
}
|
||||
|
||||
function busy() {
|
||||
root.classList.toggle('vino-cart--busy', inflight > 0 || Object.keys(timers).length > 0);
|
||||
}
|
||||
|
||||
function request(action, data) {
|
||||
var run = function () {
|
||||
return BX.ajax.runAction('jinove:vinoteca.basket.' + action, { data: data || {} });
|
||||
};
|
||||
inflight++;
|
||||
busy();
|
||||
var result = queue.then(run);
|
||||
queue = result.then(noop, noop);
|
||||
queue.then(function () {
|
||||
inflight--;
|
||||
busy();
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
function call(action, data) {
|
||||
version++;
|
||||
var sent = version;
|
||||
return request(action, data).then(function (res) {
|
||||
apply(res, sent);
|
||||
return res;
|
||||
}, function (res) {
|
||||
recover(sent);
|
||||
throw res;
|
||||
});
|
||||
}
|
||||
|
||||
function send(id, qty) {
|
||||
clearTimeout(timers[id]);
|
||||
timers[id] = setTimeout(function () {
|
||||
delete timers[id];
|
||||
call('update', { id: id, qty: qty }).then(noop, noop);
|
||||
}, 350);
|
||||
busy();
|
||||
}
|
||||
|
||||
function cancel(id) {
|
||||
clearTimeout(timers[id]);
|
||||
delete timers[id];
|
||||
busy();
|
||||
}
|
||||
|
||||
function step(li, delta) {
|
||||
var id = li.getAttribute('data-cart-item');
|
||||
var value = field(li, 'value');
|
||||
var qty = Math.max(1, Math.min(max, (parseInt(value.textContent, 10) || 1) + delta));
|
||||
if (String(qty) === value.textContent) return;
|
||||
value.textContent = qty;
|
||||
send(id, qty);
|
||||
}
|
||||
|
||||
function remove(li) {
|
||||
var id = li.getAttribute('data-cart-item');
|
||||
li.setAttribute('data-cart-was', field(li, 'value').textContent);
|
||||
cancel(id);
|
||||
lock(li, true);
|
||||
field(li, 'restore').focus();
|
||||
call('update', { id: id, qty: 0 }).then(noop, noop);
|
||||
}
|
||||
|
||||
function restore(li) {
|
||||
var id = li.getAttribute('data-cart-item');
|
||||
var qty = parseInt(li.getAttribute('data-cart-was'), 10) || 1;
|
||||
cancel(id);
|
||||
lock(li, false);
|
||||
field(li, 'value').textContent = qty;
|
||||
field(li, 'remove').focus();
|
||||
call('update', { id: id, qty: qty }).then(noop, noop);
|
||||
}
|
||||
|
||||
function flush() {
|
||||
Object.keys(timers).forEach(function (id) {
|
||||
var li = item(id);
|
||||
cancel(id);
|
||||
if (li) call('update', { id: id, qty: parseInt(field(li, 'value').textContent, 10) || 1 }).then(noop, noop);
|
||||
});
|
||||
}
|
||||
|
||||
function checkout(link, e) {
|
||||
if (!root.classList.contains('vino-cart--busy')) return;
|
||||
e.preventDefault();
|
||||
if (link.getAttribute('aria-busy') === 'true') return;
|
||||
link.setAttribute('aria-busy', 'true');
|
||||
flush();
|
||||
queue.then(function () {
|
||||
link.removeAttribute('aria-busy');
|
||||
if (fail.hidden) location.href = link.href;
|
||||
});
|
||||
}
|
||||
|
||||
function toggleConfirm(on) {
|
||||
confirmBox.hidden = !on;
|
||||
actions.hidden = on;
|
||||
(on ? root.querySelector('[data-cart-clear-no]') : clearButton).focus();
|
||||
}
|
||||
|
||||
function clearCart() {
|
||||
confirmBox.hidden = true;
|
||||
actions.hidden = false;
|
||||
Object.keys(timers).forEach(cancel);
|
||||
clearing = true;
|
||||
layout.hidden = true;
|
||||
empty.hidden = false;
|
||||
emptyTitle.focus();
|
||||
call('clear').then(noop, noop).then(function () { clearing = false; });
|
||||
}
|
||||
|
||||
function shareLink() {
|
||||
var pairs = [];
|
||||
root.querySelectorAll('[data-cart-item]:not(.vino-cart__item--removed)').forEach(function (li) {
|
||||
pairs.push(li.getAttribute('data-cart-item') + '-' + (parseInt(field(li, 'value').textContent, 10) || 1));
|
||||
});
|
||||
return location.origin + location.pathname + '?share=' + pairs.join('.');
|
||||
}
|
||||
|
||||
function copied() {
|
||||
var done = root.querySelector('[data-cart-share-done]').textContent;
|
||||
shareButton.classList.add('vino-cart__share--done');
|
||||
shareStatus.textContent = done;
|
||||
clearTimeout(shareTimer);
|
||||
shareTimer = setTimeout(function () {
|
||||
shareButton.classList.remove('vino-cart__share--done');
|
||||
shareStatus.textContent = '';
|
||||
}, 2500);
|
||||
}
|
||||
|
||||
function showLink(link) {
|
||||
var input = shareFallback.querySelector('[data-cart-share-input]');
|
||||
input.value = link;
|
||||
shareFallback.hidden = false;
|
||||
input.focus();
|
||||
input.select();
|
||||
}
|
||||
|
||||
function share() {
|
||||
var link = shareLink();
|
||||
shareFallback.hidden = true;
|
||||
if (navigator.share && window.matchMedia('(pointer: coarse)').matches) {
|
||||
navigator.share({ title: shareButton.getAttribute('data-title'), url: link }).catch(noop);
|
||||
return;
|
||||
}
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
navigator.clipboard.writeText(link).then(copied, function () { showLink(link); });
|
||||
return;
|
||||
}
|
||||
showLink(link);
|
||||
}
|
||||
|
||||
function addShared(button) {
|
||||
var box = button.closest('[data-cart-shared]');
|
||||
button.disabled = true;
|
||||
BX.ajax.runAction('jinove:vinoteca.basket.addShared', { data: { code: box.getAttribute('data-cart-shared') } }).then(function () {
|
||||
location.replace(box.getAttribute('data-cart-url'));
|
||||
}, function () {
|
||||
button.disabled = false;
|
||||
showFail(true);
|
||||
});
|
||||
}
|
||||
|
||||
function expandCoupon() {
|
||||
couponExpanded = true;
|
||||
couponRowBox.hidden = false;
|
||||
couponMore.hidden = true;
|
||||
couponInput.focus();
|
||||
}
|
||||
|
||||
function couponFail(message) {
|
||||
couponError.textContent = message;
|
||||
couponError.hidden = !message;
|
||||
couponForm.classList.toggle('vino-cart__coupon--error', !!message);
|
||||
couponInput.setAttribute('aria-invalid', message ? 'true' : 'false');
|
||||
}
|
||||
|
||||
root.addEventListener('click', function (e) {
|
||||
var target = e.target.closest('button');
|
||||
if (!target || !root.contains(target)) return;
|
||||
var li = target.closest('[data-cart-item]');
|
||||
if (target.hasAttribute('data-cart-step') && li) step(li, parseInt(target.getAttribute('data-cart-step'), 10));
|
||||
else if (target.hasAttribute('data-cart-remove') && li) remove(li);
|
||||
else if (target.hasAttribute('data-cart-restore') && li) restore(li);
|
||||
else if (target.hasAttribute('data-cart-share')) share();
|
||||
else if (target.hasAttribute('data-cart-shared-add')) addShared(target);
|
||||
else if (target.hasAttribute('data-cart-coupon-more')) expandCoupon();
|
||||
else if (target.hasAttribute('data-cart-clear')) toggleConfirm(true);
|
||||
else if (target.hasAttribute('data-cart-clear-no')) toggleConfirm(false);
|
||||
else if (target.hasAttribute('data-cart-clear-yes')) clearCart();
|
||||
else if (target.hasAttribute('data-cart-coupon-remove')) {
|
||||
call('couponRemove', { code: target.getAttribute('data-cart-coupon-remove') }).then(function () { couponInput.focus(); }, noop);
|
||||
}
|
||||
});
|
||||
|
||||
root.addEventListener('click', function (e) {
|
||||
var link = e.target.closest('[data-cart-checkout]');
|
||||
if (link) checkout(link, e);
|
||||
});
|
||||
|
||||
root.addEventListener('keydown', function (e) {
|
||||
if (e.key !== 'Escape') return;
|
||||
if (!confirmBox.hidden) toggleConfirm(false);
|
||||
else if (!shareFallback.hidden) {
|
||||
shareFallback.hidden = true;
|
||||
shareButton.focus();
|
||||
}
|
||||
});
|
||||
|
||||
couponForm.addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var code = couponInput.value.trim();
|
||||
if (!code) {
|
||||
couponFail(text('coupon-empty'));
|
||||
couponInput.focus();
|
||||
return;
|
||||
}
|
||||
couponFail('');
|
||||
var button = couponForm.querySelector('[type="submit"]');
|
||||
button.disabled = true;
|
||||
version++;
|
||||
var sent = version;
|
||||
request('coupon', { code: code }).then(function (res) {
|
||||
button.disabled = false;
|
||||
couponInput.value = '';
|
||||
couponExpanded = false;
|
||||
apply(res, sent);
|
||||
var chip = couponList.querySelector('button');
|
||||
if (chip) chip.focus();
|
||||
}, function (res) {
|
||||
var error = res && res.errors && res.errors[0];
|
||||
button.disabled = false;
|
||||
if (error && error.code === 'coupon') couponFail(text('coupon-error'));
|
||||
else showFail(true);
|
||||
couponInput.focus();
|
||||
});
|
||||
});
|
||||
|
||||
couponHint.addEventListener('click', function (e) {
|
||||
var fill = e.target.closest('[data-cart-coupon-fill]');
|
||||
if (!fill) return;
|
||||
couponInput.value = fill.getAttribute('data-cart-coupon-fill');
|
||||
couponInput.dispatchEvent(new Event('input'));
|
||||
couponInput.focus();
|
||||
});
|
||||
|
||||
couponInput.addEventListener('input', function () {
|
||||
if (!couponError.hidden) couponFail('');
|
||||
});
|
||||
})();
|
||||
@@ -0,0 +1,659 @@
|
||||
.vino-cart {
|
||||
--vino-cart-summary-width: 360px;
|
||||
--vino-cart-field-height: 48px;
|
||||
--vino-cart-qty-width: 120px;
|
||||
--vino-cart-shared-sum-width: 110px;
|
||||
--vino-cart-icon-sm: 14px;
|
||||
--vino-cart-icon: 20px;
|
||||
--vino-cart-disabled-opacity: .45;
|
||||
--vino-cart-shared-pic-width: 72px;
|
||||
--vino-cart-shared-pic-height: 90px;
|
||||
--vino-cart-pic-width: 80px;
|
||||
--vino-cart-pic-height: 100px;
|
||||
padding: var(--space-10) var(--gutter) var(--space-section);
|
||||
}
|
||||
.vino-cart__layout,
|
||||
.vino-cart__empty {
|
||||
max-width: var(--container);
|
||||
margin: 0 auto;
|
||||
}
|
||||
.vino-cart__layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) var(--vino-cart-summary-width);
|
||||
gap: var(--space-grid-wide);
|
||||
align-items: start;
|
||||
}
|
||||
.vino-cart__layout[hidden],
|
||||
.vino-cart__empty[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.vino-cart__main {
|
||||
min-width: 0;
|
||||
container: vino-cart-main / inline-size;
|
||||
}
|
||||
.vino-cart__toolbar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3) var(--space-6);
|
||||
min-height: var(--size-tap);
|
||||
padding-bottom: var(--space-4);
|
||||
border-bottom: 1px solid var(--color-line);
|
||||
}
|
||||
.vino-cart__count {
|
||||
margin: 0;
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--text-15);
|
||||
}
|
||||
.vino-cart__actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0 var(--space-6);
|
||||
}
|
||||
.vino-cart__actions[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.vino-cart__share {
|
||||
display: inline-grid;
|
||||
align-items: center;
|
||||
}
|
||||
.vino-cart__share-label {
|
||||
grid-area: 1 / 1;
|
||||
transition: opacity var(--duration-fast) var(--ease-base);
|
||||
}
|
||||
.vino-cart__share-label--done,
|
||||
.vino-cart__share--done .vino-cart__share-label--idle {
|
||||
opacity: 0;
|
||||
}
|
||||
.vino-cart__share--done .vino-cart__share-label--done {
|
||||
opacity: 1;
|
||||
}
|
||||
.vino-cart__share-fallback {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
z-index: 2;
|
||||
display: block;
|
||||
width: min(420px, 100%);
|
||||
margin-top: var(--space-2);
|
||||
padding: var(--space-3);
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-line);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
.vino-cart__share-fallback[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.vino-cart__share-input.vino-inp {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
.vino-cart__shared {
|
||||
max-width: var(--container);
|
||||
margin: 0 auto var(--space-10);
|
||||
padding: var(--space-card);
|
||||
background: var(--color-surface);
|
||||
border: 1px solid color-mix(in srgb, var(--color-accent) 40%, transparent);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
.vino-cart__shared-title {
|
||||
margin: 0;
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--fs-h4);
|
||||
font-weight: 400;
|
||||
line-height: var(--leading-title);
|
||||
}
|
||||
.vino-cart__shared-hint {
|
||||
margin: var(--space-2) 0 0;
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--text-15);
|
||||
}
|
||||
.vino-cart__shared-list {
|
||||
margin: var(--space-4) 0 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.vino-cart__shared-item {
|
||||
display: grid;
|
||||
grid-template-columns: var(--vino-cart-shared-pic-width) minmax(0, 1fr) auto var(--vino-cart-shared-sum-width);
|
||||
align-items: center;
|
||||
gap: var(--space-4);
|
||||
padding: var(--space-2) 0;
|
||||
border-bottom: 1px solid var(--color-line);
|
||||
font-size: var(--text-15);
|
||||
}
|
||||
.vino-cart__shared-pic {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: var(--vino-cart-shared-pic-width);
|
||||
height: var(--vino-cart-shared-pic-height);
|
||||
background: var(--color-bg);
|
||||
border-radius: var(--radius-sm);
|
||||
overflow: hidden;
|
||||
}
|
||||
.vino-cart__shared-name {
|
||||
color: var(--color-text);
|
||||
text-decoration: none;
|
||||
transition: color var(--duration-fast) var(--ease-base);
|
||||
}
|
||||
.vino-cart__shared-qty {
|
||||
color: var(--color-text-muted);
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.vino-cart__shared-sum {
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.vino-cart__shared-foot {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
margin-top: var(--space-4);
|
||||
}
|
||||
.vino-cart__shared-total {
|
||||
margin: 0 auto 0 0;
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--text-15);
|
||||
}
|
||||
.vino-cart__shared-total-value {
|
||||
color: var(--color-text);
|
||||
font-weight: 600;
|
||||
}
|
||||
.vino-cart__link,
|
||||
.vino-cart__restore {
|
||||
min-height: var(--size-tap);
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--color-accent);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--text-13);
|
||||
letter-spacing: var(--tracking-sm);
|
||||
text-transform: uppercase;
|
||||
cursor: pointer;
|
||||
}
|
||||
.vino-cart__confirm {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
.vino-cart__confirm[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.vino-cart__confirm-text {
|
||||
margin: 0;
|
||||
font-size: var(--text-15);
|
||||
}
|
||||
.vino-cart__fail {
|
||||
margin: var(--space-4) 0 0;
|
||||
color: var(--color-danger-soft);
|
||||
font-size: var(--text-15);
|
||||
}
|
||||
.vino-cart__list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.vino-cart__item {
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-columns: var(--vino-cart-pic-width) minmax(0, 1fr) auto var(--vino-cart-qty-width) var(--size-tap);
|
||||
align-items: center;
|
||||
gap: var(--space-6);
|
||||
padding: var(--space-4) 0;
|
||||
border-bottom: 1px solid var(--color-line);
|
||||
}
|
||||
.vino-cart__pic {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: var(--vino-cart-pic-width);
|
||||
height: var(--vino-cart-pic-height);
|
||||
background: var(--color-surface);
|
||||
border-radius: var(--radius-sm);
|
||||
overflow: hidden;
|
||||
}
|
||||
.vino-cart__img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
.vino-cart__info {
|
||||
min-width: 0;
|
||||
}
|
||||
.vino-cart__name {
|
||||
display: inline-block;
|
||||
color: var(--color-text);
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--fs-h4);
|
||||
line-height: var(--leading-title);
|
||||
text-decoration: none;
|
||||
transition: color var(--duration-fast) var(--ease-base);
|
||||
}
|
||||
.vino-cart__meta {
|
||||
margin: var(--space-1) 0 0;
|
||||
color: var(--color-text-faint);
|
||||
font-size: var(--text-13);
|
||||
line-height: var(--leading-ui);
|
||||
}
|
||||
.vino-cart__unit {
|
||||
margin: var(--space-2) 0 0;
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--text-13);
|
||||
}
|
||||
.vino-cart__old {
|
||||
margin-left: var(--space-2);
|
||||
color: var(--color-text-faint);
|
||||
}
|
||||
.vino-cart__old[hidden],
|
||||
.vino-cart__warning[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.vino-cart__warning {
|
||||
margin: var(--space-2) 0 0;
|
||||
color: var(--color-danger-soft);
|
||||
font-size: var(--text-13);
|
||||
}
|
||||
.vino-cart__item--unavailable .vino-cart__pic,
|
||||
.vino-cart__item--unavailable .vino-cart__sum {
|
||||
opacity: var(--vino-cart-disabled-opacity);
|
||||
}
|
||||
.vino-cart__qty {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: var(--size-tap);
|
||||
border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 55%, transparent);
|
||||
border-radius: 0;
|
||||
}
|
||||
.vino-cart__step {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: var(--size-tap);
|
||||
height: calc(var(--size-tap) - 1px);
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
background: transparent;
|
||||
color: var(--color-accent);
|
||||
cursor: pointer;
|
||||
transition: background var(--duration-fast) var(--ease-base), color var(--duration-fast) var(--ease-base);
|
||||
}
|
||||
.vino-cart__step-icon {
|
||||
width: var(--vino-cart-icon-sm);
|
||||
height: var(--vino-cart-icon-sm);
|
||||
}
|
||||
.vino-cart__value {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
align-self: stretch;
|
||||
min-width: 3ch;
|
||||
color: var(--color-text);
|
||||
font-size: var(--text-15);
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: center;
|
||||
}
|
||||
.vino-cart__sum {
|
||||
margin: 0;
|
||||
color: var(--color-accent);
|
||||
font-size: var(--text-17);
|
||||
font-weight: 600;
|
||||
font-variant-numeric: tabular-nums;
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.vino-cart__remove,
|
||||
.vino-cart__coupon-remove {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: var(--size-tap);
|
||||
height: var(--size-tap);
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--color-text-faint);
|
||||
cursor: pointer;
|
||||
transition: color var(--duration-fast) var(--ease-base);
|
||||
}
|
||||
.vino-cart__remove-icon {
|
||||
width: var(--vino-cart-icon);
|
||||
height: var(--vino-cart-icon);
|
||||
}
|
||||
.vino-cart__removed {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-4);
|
||||
padding: 0 var(--space-4);
|
||||
background: var(--color-bg);
|
||||
font-size: var(--text-15);
|
||||
}
|
||||
.vino-cart__removed[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.vino-cart__removed-text {
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
.vino-cart__summary {
|
||||
position: sticky;
|
||||
top: calc(var(--size-header) + var(--space-6));
|
||||
padding: var(--space-card);
|
||||
background: var(--color-surface);
|
||||
border: 1px solid var(--color-line);
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
.vino-cart__summary-title {
|
||||
margin: 0 0 var(--space-6);
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--fs-h4);
|
||||
font-weight: 400;
|
||||
line-height: var(--leading-title);
|
||||
}
|
||||
.vino-cart__coupon-head {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-3);
|
||||
margin-bottom: var(--space-2);
|
||||
}
|
||||
.vino-cart__coupon-more {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--color-accent);
|
||||
font-family: var(--font-sans);
|
||||
font-size: var(--text-13);
|
||||
cursor: pointer;
|
||||
transition: color var(--duration-fast) var(--ease-base);
|
||||
}
|
||||
.vino-cart__coupon-more[hidden] {
|
||||
display: inline;
|
||||
visibility: hidden;
|
||||
}
|
||||
.vino-cart__coupon-more::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: -12px -8px;
|
||||
}
|
||||
.vino-cart__label {
|
||||
display: block;
|
||||
margin-bottom: var(--space-2);
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--text-13);
|
||||
}
|
||||
.vino-cart__coupon-head .vino-cart__label {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.vino-cart__coupon-row {
|
||||
display: flex;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
.vino-cart__coupon-row[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.vino-cart__coupon-row:not([hidden]) + .vino-cart__coupons:not(:empty) {
|
||||
margin-top: var(--space-3);
|
||||
}
|
||||
.vino-cart__coupon-hint {
|
||||
margin: var(--space-2) 0 0;
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--text-13);
|
||||
line-height: var(--leading-ui);
|
||||
}
|
||||
.vino-cart__coupon-hint-line {
|
||||
display: block;
|
||||
}
|
||||
.vino-cart__coupon-fill {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: var(--color-accent);
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: color var(--duration-fast) var(--ease-base), transform var(--duration-fast) var(--ease-base);
|
||||
}
|
||||
.vino-cart__coupon-fill:active {
|
||||
transform: scale(.97);
|
||||
}
|
||||
.vino-cart__coupon-hint[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.vino-cart__coupon-input.vino-inp {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
min-height: var(--vino-cart-field-height);
|
||||
margin: 0;
|
||||
background: transparent;
|
||||
}
|
||||
.vino-cart__coupon-apply.vino-btn {
|
||||
flex: 0 0 auto;
|
||||
justify-content: center;
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.vino-cart__coupon--error .vino-cart__coupon-input {
|
||||
border-color: var(--color-danger-soft);
|
||||
box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-danger-soft) 22%, transparent);
|
||||
}
|
||||
.vino-cart__error {
|
||||
min-height: calc(var(--text-13) * 1.45);
|
||||
margin: var(--space-2) 0 0;
|
||||
color: var(--color-danger-soft);
|
||||
font-size: var(--text-13);
|
||||
line-height: var(--leading-ui);
|
||||
}
|
||||
.vino-cart__error[hidden] {
|
||||
display: block;
|
||||
visibility: hidden;
|
||||
}
|
||||
.vino-cart__coupons {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.vino-cart__coupon-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: var(--vino-cart-field-height);
|
||||
justify-content: space-between;
|
||||
padding-left: var(--space-3);
|
||||
border: 1px dashed var(--color-line-field);
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: var(--text-15);
|
||||
letter-spacing: var(--tracking-xs);
|
||||
}
|
||||
.vino-cart__coupon-item + .vino-cart__coupon-item {
|
||||
margin-top: var(--space-2);
|
||||
}
|
||||
.vino-cart__totals {
|
||||
margin: 0 0 var(--space-6);
|
||||
padding-top: var(--space-4);
|
||||
border-top: 1px solid var(--color-line);
|
||||
}
|
||||
.vino-cart__sum,
|
||||
.vino-cart__count,
|
||||
.vino-cart__totals {
|
||||
transition: opacity var(--duration-fast) var(--ease-base);
|
||||
}
|
||||
.vino-cart__checkout[aria-busy="true"] {
|
||||
opacity: .6;
|
||||
pointer-events: none;
|
||||
}
|
||||
.vino-cart--busy .vino-cart__sum,
|
||||
.vino-cart--busy .vino-cart__count,
|
||||
.vino-cart--busy .vino-cart__totals {
|
||||
opacity: .45;
|
||||
}
|
||||
.vino-cart__line {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: var(--space-4);
|
||||
padding: var(--space-1) 0;
|
||||
color: var(--color-text-muted);
|
||||
font-size: var(--text-15);
|
||||
}
|
||||
.vino-cart__line[hidden] {
|
||||
display: none;
|
||||
}
|
||||
.vino-cart__term,
|
||||
.vino-cart__value-line {
|
||||
margin: 0;
|
||||
}
|
||||
.vino-cart__value-line {
|
||||
font-variant-numeric: tabular-nums;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.vino-cart__line--discount .vino-cart__value-line {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
.vino-cart__line--none .vino-cart__value-line {
|
||||
color: var(--color-text-faint);
|
||||
}
|
||||
.vino-cart__line--total {
|
||||
margin-top: var(--space-2);
|
||||
color: var(--color-text);
|
||||
font-size: var(--text-19);
|
||||
font-weight: 600;
|
||||
}
|
||||
.vino-cart__checkout {
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
min-height: var(--size-tap);
|
||||
}
|
||||
.vino-cart__empty {
|
||||
padding: var(--space-16) 0;
|
||||
text-align: center;
|
||||
}
|
||||
.vino-cart__empty-title {
|
||||
margin: 0;
|
||||
font-family: var(--font-serif);
|
||||
font-size: var(--fs-h3);
|
||||
line-height: var(--leading-title);
|
||||
}
|
||||
.vino-cart__empty-text {
|
||||
margin: var(--space-3) 0 var(--space-8);
|
||||
color: var(--color-text-muted);
|
||||
}
|
||||
@media (hover: hover) {
|
||||
.vino-cart__coupon-apply.vino-btn:hover {
|
||||
transform: none;
|
||||
}
|
||||
.vino-cart__coupon-more:hover,
|
||||
.vino-cart__coupon-fill:hover {
|
||||
color: var(--color-accent-hover);
|
||||
}
|
||||
.vino-cart__name:hover,
|
||||
.vino-cart__shared-name:hover {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
.vino-cart__step:hover {
|
||||
color: var(--color-text);
|
||||
}
|
||||
.vino-cart__remove:hover,
|
||||
.vino-cart__coupon-remove:hover {
|
||||
color: var(--color-accent);
|
||||
}
|
||||
.vino-cart__link:hover,
|
||||
.vino-cart__restore:hover {
|
||||
color: var(--color-accent-hover);
|
||||
}
|
||||
}
|
||||
@media (pointer: coarse) {
|
||||
.vino-cart__name,
|
||||
.vino-cart__shared-name {
|
||||
position: relative;
|
||||
}
|
||||
.vino-cart__name::before,
|
||||
.vino-cart__shared-name::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: calc((var(--size-tap) - 100%) / -2) 0;
|
||||
}
|
||||
}
|
||||
@media (max-width: 980px) {
|
||||
.vino-cart__layout {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.vino-cart__summary {
|
||||
position: static;
|
||||
}
|
||||
}
|
||||
@media (max-width: 560px) {
|
||||
.vino-cart {
|
||||
--vino-cart-pic-width: 72px;
|
||||
--vino-cart-pic-height: 90px;
|
||||
padding-top: var(--space-6);
|
||||
}
|
||||
.vino-cart__shared-item {
|
||||
grid-template-columns: var(--vino-cart-shared-pic-width) auto minmax(0, 1fr);
|
||||
grid-template-areas:
|
||||
"pic name name"
|
||||
"pic qty sum";
|
||||
gap: var(--space-1) var(--space-4);
|
||||
}
|
||||
.vino-cart__shared-pic {
|
||||
grid-area: pic;
|
||||
}
|
||||
.vino-cart__shared-total {
|
||||
flex: 1 1 100%;
|
||||
}
|
||||
.vino-cart__shared-button.vino-btn {
|
||||
flex: 1 1 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
.vino-cart__shared-name {
|
||||
grid-area: name;
|
||||
}
|
||||
.vino-cart__shared-qty {
|
||||
grid-area: qty;
|
||||
}
|
||||
.vino-cart__shared-sum {
|
||||
grid-area: sum;
|
||||
}
|
||||
}
|
||||
@container vino-cart-main (max-width: 640px) {
|
||||
.vino-cart__item {
|
||||
grid-template-columns: var(--vino-cart-pic-width) auto minmax(0, 1fr) var(--size-tap);
|
||||
grid-template-areas:
|
||||
"pic info info remove"
|
||||
"pic qty sum sum";
|
||||
gap: var(--space-3) var(--space-4);
|
||||
}
|
||||
.vino-cart__pic {
|
||||
grid-area: pic;
|
||||
align-self: start;
|
||||
}
|
||||
.vino-cart__info {
|
||||
grid-area: info;
|
||||
}
|
||||
.vino-cart__qty {
|
||||
grid-area: qty;
|
||||
justify-self: start;
|
||||
}
|
||||
.vino-cart__sum {
|
||||
grid-area: sum;
|
||||
justify-self: end;
|
||||
}
|
||||
.vino-cart__remove {
|
||||
grid-area: remove;
|
||||
align-self: start;
|
||||
}
|
||||
}
|
||||
.vino-cart .vino-btn--sm {
|
||||
min-height: var(--size-tap);
|
||||
justify-content: center;
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
<?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"] === "" ? "—" : 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>
|
||||
Reference in new issue
Block a user