- Cart
- Delivery and payment
- Order confirmation
Cart
Delivery and payment
Order confirmation
jQuery(function ($) {
const pageLanguage = (
document.documentElement.lang || ''
).toLowerCase();
const isEN = pageLanguage.startsWith('en');
// Keep only the most recently displayed Fly Cart item.
function keepOnlyLastCartItem() {
const $cartItems = $('.woofc-item');
if ($cartItems.length > 1) {
$cartItems.slice(0, -1).remove();
}
}
// Prevent attaching the same observer repeatedly.
function observeCart() {
const targetNode = document.querySelector('.woofc-area-mid');
if (!targetNode || targetNode.dataset.zendoObserved === 'true') {
return;
}
targetNode.dataset.zendoObserved = 'true';
const observer = new MutationObserver(function () {
keepOnlyLastCartItem();
});
observer.observe(targetNode, {
childList: true,
subtree: false
});
}
const bodyObserver = new MutationObserver(function () {
observeCart();
keepOnlyLastCartItem();
});
bodyObserver.observe(document.body, {
childList: true,
subtree: true
});
function replaceAddToCartText() {
$('a.add_to_cart_button').each(function () {
$(this).html(
''
);
$(this).attr(
'aria-label',
isEN ? 'Add to cart' : 'Добави в количката'
);
});
}
function runTranslations() {
if (isEN) {
$('.woofc-area-top').each(function () {
if (!$(this).find('.woofc-added-banner').length) {
$(
'
' +
' ' +
'Product added to cart' +
'
'
).prependTo(this);
}
});
$('.checkout-button, .woofc-action-checkout')
.text('To Delivery & Payment');
const shopBtn = document.querySelector(
'.elementor-element-6965a18 a.elementor-button'
);
const shopText = document.querySelector(
'.elementor-element-6965a18 .elementor-button-text'
);
if (shopBtn) {
shopBtn.href = 'https://zendosounds.bg/en/handpans/';
}
if (shopText) {
shopText.textContent = 'To Zendō Shop';
}
} else {
$('.checkout-button, .woofc-action-checkout')
.text('Към доставка и плащане');
$('.woofc-area-top').each(function () {
if (!$(this).find('.woofc-added-banner').length) {
$(
'' +
' ' +
'Продуктът е добавен в количката' +
'
'
).prependTo(this);
}
});
}
}
function initializeZendoCart() {
observeCart();
keepOnlyLastCartItem();
replaceAddToCartText();
runTranslations();
}
initializeZendoCart();
$(document.body).on(
'updated_wc_div wc_fragments_loaded woofc_loaded',
initializeZendoCart
);
window.setTimeout(initializeZendoCart, 500);
});
