function on_keydown_remove_from_cart(e){" "===e.key&&(e.preventDefault(),e.currentTarget.click())}function focus_populate_live_region(){var e=["woocommerce-message","woocommerce-error","wc-block-components-notice-banner"].map(function(e){return"."+e+'[role="alert"]'}).join(", "),o=document.querySelectorAll(e);if(0!==o.length){var t=o[0];t.setAttribute("tabindex","-1");var n=setTimeout(function(){t.focus(),clearTimeout(n)},500)}}function refresh_sorted_by_live_region(){var e=document.querySelector(".woocommerce-result-count"),o=document.querySelector('[data-wp-interactive="woocommerce/product-filters"]');if(e&&window.location.search&&!o){var t=e.innerHTML;e.setAttribute("role","alert"),e.setAttribute("aria-hidden","true");var n=setTimeout(function(){e.setAttribute("aria-hidden","false"),e.innerHTML="",e.innerHTML=t,clearTimeout(n)},2e3)}}function on_document_ready(){focus_populate_live_region(),refresh_sorted_by_live_region()}jQuery(function(e){e(".woocommerce-ordering").on("change","select.orderby",function(){e(this).closest("form").trigger("submit")}),e("input.qty:not(.product-quantity input.qty)").each(function(){var o=parseFloat(e(this).attr("min"));o>=0&&parseFloat(e(this).val())<o&&e(this).val(o)});var o="store_notice"+(e(".woocommerce-store-notice").data("noticeId")||"");if("hidden"===Cookies.get(o))e(".woocommerce-store-notice").hide();else{function t(o){["Enter"," "].includes(o.key)&&(o.preventDefault(),e(".woocommerce-store-notice__dismiss-link").click())}e(".woocommerce-store-notice").show(),e(".woocommerce-store-notice__dismiss-link").on("click",function n(r){Cookies.set(o,"hidden",{path:"/"}),e(".woocommerce-store-notice").hide(),r.preventDefault(),e(".woocommerce-store-notice__dismiss-link").off("click",n).off("keydown",t)}).on("keydown",t)}e(".woocommerce-input-wrapper span.description").length&&e(document.body).on("click",function(){e(".woocommerce-input-wrapper span.description:visible").prop("aria-hidden",!0).slideUp(250)}),e(".woocommerce-input-wrapper").on("click",function(e){e.stopPropagation()}),e(".woocommerce-input-wrapper :input").on("keydown",function(o){var t=e(this).parent().find("span.description");if(27===o.which&&t.length&&t.is(":visible"))return t.prop("aria-hidden",!0).slideUp(250),o.preventDefault(),!1}).on("click focus",function(){var o=e(this).parent(),t=o.find("span.description");o.addClass("currentTarget"),e(".woocommerce-input-wrapper:not(.currentTarget) span.description:visible").prop("aria-hidden",!0).slideUp(250),t.length&&t.is(":hidden")&&t.prop("aria-hidden",!1).slideDown(250),o.removeClass("currentTarget")}),e.scroll_to_notices=function(o){o.length&&e("html, body").animate({scrollTop:o.offset().top-100},1e3)},e('.woocommerce form .woocommerce-Input[type="password"]').wrap('<span class="password-input"></span>'),e(".woocommerce form input").filter(":password").parent("span").addClass("password-input"),e(".password-input").each(function(){const o=e(this).find("input").attr("id");e(this).append('<button type="button" class="show-password-input" aria-label="'+woocommerce_params.i18n_password_show+'" aria-describedBy="'+o+'"></button>')}),e(".show-password-input").on("click",function(o){o.preventDefault(),e(this).hasClass("display-password")?(e(this).removeClass("display-password"),e(this).attr("aria-label",woocommerce_params.i18n_password_show)):(e(this).addClass("display-password"),e(this).attr("aria-label",woocommerce_params.i18n_password_hide)),e(this).hasClass("display-password")?e(this).siblings(['input[type="password"]']).prop("type","text"):e(this).siblings('input[type="text"]').prop("type","password"),e(this).siblings("input").focus()}),e("a.coming-soon-footer-banner-dismiss").on("click",function(o){var t=e(o.target);e.ajax({type:"post",url:t.data("rest-url"),data:{woocommerce_meta:{coming_soon_banner_dismissed:"yes"}},beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",t.data("rest-nonce"))},complete:function(){e("#coming-soon-footer-banner").hide()}})}),"undefined"==typeof wc_add_to_cart_params&&e(document.body).on("keydown",".remove_from_cart_button",on_keydown_remove_from_cart),e(document.body).on("item_removed_from_classic_cart updated_wc_div",focus_populate_live_region)}),document.addEventListener("DOMContentLoaded",on_document_ready);
(function($){
'use strict';
if(typeof abovewpBGE==='undefined'){
console.error('AboveWP Bulgarian Eurozone: Missing conversion data');
return;
}
const conversionRate=abovewpBGE.conversionRate;
const primaryCurrency=abovewpBGE.primaryCurrency; // 'BGN' or 'EUR'
const secondaryCurrency=abovewpBGE.secondaryCurrency; // 'EUR' or 'BGN'
const eurLabel=abovewpBGE.eurLabel||'€';
const bgnLabel=abovewpBGE.bgnLabel||'лв.';
const secondaryLabel=abovewpBGE.secondaryLabel;
const eurPosition=abovewpBGE.eurPosition||'right';
const eurFormat=abovewpBGE.eurFormat||'brackets';
const bgnRounding=abovewpBGE.bgnRounding||'smart';
function normalizePrice(price){
let normalizedPrice=String(price);
const decimalMatch=normalizedPrice.match(/[.,](\d{2})$/);
if(decimalMatch){
const decimalPart=decimalMatch[1];
const integerPart=normalizedPrice.substring(0, normalizedPrice.length - 3);
const cleanIntegerPart=integerPart.replace(/[\s.]/g, '');
normalizedPrice=cleanIntegerPart + '.' + decimalPart;
}else{
normalizedPrice=normalizedPrice.replace(/[\s.,]/g, '');
}
return parseFloat(normalizedPrice);
}
function convertBgnToEur(bgnPrice){
return (normalizePrice(bgnPrice) / conversionRate).toFixed(2);
}
function convertEurToBgn(eurPrice){
var raw=normalizePrice(eurPrice) * conversionRate;
var rounded=Math.round(raw * 100) / 100;
if(bgnRounding==='smart'){
var nearestInt=Math.round(rounded);
if(Math.abs(rounded - nearestInt) < 0.015){
return nearestInt.toFixed(2);
}}
return rounded.toFixed(2);
}
function convertToSecondary(price){
if(primaryCurrency==='BGN'){
return convertBgnToEur(price);
}else if(primaryCurrency==='EUR'){
return convertEurToBgn(price);
}
return price;
}
function formatSecondaryPrice(secondaryPrice){
if(eurFormat==='divider'){
return '/ ' + secondaryPrice + ' ' + secondaryLabel;
}else{
return '(' + secondaryPrice + ' ' + secondaryLabel + ')';
}}
function formatDualPrice(primaryPriceHtml, secondaryPrice){
const secondaryFormatted=formatSecondaryPrice(secondaryPrice);
const secondarySpan='<span class="eur-price">' + secondaryFormatted + '</span>';
if(eurPosition==='left'){
return secondarySpan + ' ' + primaryPriceHtml;
}else{
return primaryPriceHtml + ' ' + secondarySpan;
}}
function hasSecondaryPrice(element){
const $element=$(element);
if($element.find('.eur-price').length > 0 ||
$element.siblings('.eur-price').length > 0 ||
$element.next('.eur-price').length > 0 ||
$element.prev('.eur-price').length > 0){
return true;
}
if($element.parent().find('.eur-price').length > 0){
return true;
}
if($element.closest('li').find('.eur-price').length > 0){
return true;
}
const text=$element.text();
if(text.includes('(' + secondaryLabel + ')')||text.includes(secondaryLabel + ')') ||
text.includes('/ ' + secondaryLabel)||text.includes('/ ' + secondaryLabel + ')')){
return true;
}
if($element.closest('.mini_cart_item').length > 0 &&
$element.closest('.mini_cart_item').find('.eur-price').length > 0){
return true;
}
return false;
}
const hasEurPrice=hasSecondaryPrice;
function getPricePattern(){
if(primaryCurrency==='BGN'){
return /(\d+(?:[\s.]\d{3})*[.,]\d{2})\s*(?:лв\.|BGN)?/;
}else if(primaryCurrency==='EUR'){
return /(?:€\s*)?(\d+(?:[\s.]\d{3})*[.,]\d{2})\s*(?:€|EUR)?/;
}
return /(\d+(?:[\s.]\d{3})*[.,]\d{2})/;
}
function addSecondaryPrice(element){
if(hasSecondaryPrice(element)){
return;
}
const $element=$(element);
const text=$element.text().trim();
const pricePattern=getPricePattern();
const match=text.match(pricePattern);
if(match){
const pricePrimary=match[1];
const priceSecondary=convertToSecondary(pricePrimary);
const $secondarySpan=$('<span class="eur-price">' + formatSecondaryPrice(priceSecondary) + '</span>');
if(eurPosition==='left'){
$element.prepend($secondarySpan).prepend(' ');
}else{
$element.append(' ').append($secondarySpan);
}}
}
const addEurPrice=addSecondaryPrice;
function replaceDualPrice(element){
if(hasSecondaryPrice(element)){
return;
}
const $element=$(element);
let pricePrimary;
const $salePrice=$element.find('ins.wc-block-components-product-price__value, .wc-block-components-product-price__value.is-discounted');
const $regularPrice=$element.find('del.wc-block-components-product-price__regular');
if($salePrice.length > 0&&$regularPrice.length > 0){
const salePriceText=$salePrice.text().trim();
const pricePattern=getPricePattern();
const match=salePriceText.match(pricePattern);
if(match){
pricePrimary=match[1];
const priceSecondary=convertToSecondary(pricePrimary);
const secondaryFormatted=formatSecondaryPrice(priceSecondary);
const secondarySpan='<span class="eur-price">' + secondaryFormatted + '</span>';
if(eurPosition==='left'){
$element.prepend(secondarySpan + ' ');
}else{
$element.append(' ' + secondarySpan);
}
return;
}}
const originalHtml=$element.html();
const text=$element.text().trim();
const pricePattern=getPricePattern();
const match=text.match(pricePattern);
if(match){
pricePrimary=match[1];
const priceSecondary=convertToSecondary(pricePrimary);
const dualPriceHtml=formatDualPrice(originalHtml, priceSecondary);
$element.html(dualPriceHtml);
}}
function processCartItemPrices(){
$('.wc-block-components-product-price').each(function(){
if($(this).text().includes('–')||$(this).text().includes('-')){
addEurPrice(this);
}else{
replaceDualPrice(this);
}});
$('.wc-block-cart-item__total-price-and-sale-badge-wrapper .wc-block-components-product-price').each(function(){
replaceDualPrice(this);
});
}
function processCartTotals(){
$('.wc-block-components-totals-item__value').each(function(){
replaceDualPrice(this);
});
$('.wc-block-components-totals-footer-item .wc-block-components-totals-item__value').each(function(){
replaceDualPrice(this);
});
}
function processShippingMethods(){
$('#shipping_method li, .woocommerce-shipping-methods li').each(function(){
var $li=$(this);
var labelText=$li.find('label').text();
if(labelText&&(labelText.indexOf(secondaryLabel)!==-1)){
return;
}
var $priceSpan=$li.find('.woocommerce-Price-amount');
if($priceSpan.length > 0){
$priceSpan.each(function(){
var $this=$(this);
var text=$this.text().trim();
var html=$this.html();
if(!text||text.indexOf(secondaryLabel)!==-1){
return;
}
var pricePattern;
if(primaryCurrency==='BGN'){
pricePattern=/(\d+(?:[,\s.&nbsp;]\d{3})*[,\.]\d{2})\s*(?:лв\.|BGN)?/;
}else{
pricePattern=/(?:€\s*)?(\d+(?:[,\s.&nbsp;]\d{3})*[,\.]\d{2})\s*(?:€|EUR)?/;
}
var priceMatch=text.match(pricePattern)||html.match(pricePattern);
if(priceMatch){
var pricePrimaryRaw=priceMatch[1];
var pricePrimary=pricePrimaryRaw.replace(/&nbsp;/g, '').replace(/\s/g, '').replace(',', '.');
var currentPriceSecondary=convertToSecondary(pricePrimary);
var $existingSecondarySpan=$li.find('.eur-price');
if($existingSecondarySpan.length > 0){
var existingSecondaryText=$existingSecondarySpan.text();
var existingSecondaryMatch=existingSecondaryText.match(/(\d+[.,]\d{2})/);
if(existingSecondaryMatch){
var existingSecondaryPrice=existingSecondaryMatch[1].replace(',', '.');
if(Math.abs(parseFloat(currentPriceSecondary) - parseFloat(existingSecondaryPrice)) > 0.01){
$existingSecondarySpan.remove();
}else{
return;
}}else{
$existingSecondarySpan.remove();
}}
var secondaryFormatted=formatSecondaryPrice(currentPriceSecondary);
var secondarySpan='<span class="eur-price">' + secondaryFormatted + '</span>';
if(primaryCurrency==='EUR'){
$this.after(' ' + secondarySpan);
}else if(eurPosition==='left'){
$this.before(secondarySpan + ' ');
}else{
$this.after(' ' + secondarySpan);
}}
});
}});
}
function processCartFees(){
$('.fee .woocommerce-Price-amount').each(function(){
if(!hasEurPrice(this)){
addEurPrice(this);
}});
}
function processCheckoutBlockShipping(){
$('.wc-block-components-radio-control__option').each(function(){
var $option=$(this);
if($option.find('.eur-price').length > 0){
return;
}
var $priceElement=$option.find('.wc-block-formatted-money-amount.wc-block-components-formatted-money-amount');
if($priceElement.length > 0){
$priceElement.each(function(){
var $this=$(this);
var text=$this.text().trim();
if(!text||text.indexOf(secondaryLabel)!==-1||text.toLowerCase().indexOf('безплатно')!==-1||text.toLowerCase().indexOf('free')!==-1){
return;
}
var pricePattern;
if(primaryCurrency==='BGN'){
pricePattern=/(\d+(?:[,\s.]\d{3})*[,]\d{2})\s*(?:лв\.|BGN)?/;
}else{
pricePattern=/(?:€\s*)?(\d+(?:[,\s.]\d{3})*[,]\d{2})\s*(?:€|EUR)?/;
}
var priceMatch=text.match(pricePattern);
if(priceMatch){
var pricePrimary=priceMatch[1].replace(/\s/g, '').replace(',', '.');
var priceSecondary=convertToSecondary(pricePrimary);
var secondaryFormatted=formatSecondaryPrice(priceSecondary);
var secondarySpan='<span class="eur-price">' + secondaryFormatted + '</span>';
if(primaryCurrency==='EUR'){
$this.after(' ' + secondarySpan);
}else if(eurPosition==='left'){
$this.before(secondarySpan + ' ');
}else{
$this.after(' ' + secondarySpan);
}}
});
}});
$('.wc-block-components-totals-shipping .wc-block-formatted-money-amount, .wc-block-components-totals-item .wc-block-components-totals-item__value').each(function(){
var $this=$(this);
var $totalsItem=$this.closest('.wc-block-components-totals-item');
if($totalsItem.length > 0){
var labelText=$totalsItem.find('.wc-block-components-totals-item__label').text().toLowerCase();
if(labelText.indexOf('доставка')===-1 &&
labelText.indexOf('shipping')===-1 &&
labelText.indexOf('delivery')===-1){
return;
}}
if(!hasSecondaryPrice(this)){
var text=$this.text().trim();
if(text&&text.indexOf(secondaryLabel)===-1 &&
text.toLowerCase().indexOf('безплатно')===-1 &&
text.toLowerCase().indexOf('free')===-1){
var pricePattern=getPricePattern();
var priceMatch=text.match(pricePattern);
if(priceMatch){
var pricePrimary=priceMatch[1].replace(/\s/g, '').replace(',', '.');
var priceSecondary=convertToSecondary(pricePrimary);
var secondaryFormatted=formatSecondaryPrice(priceSecondary);
var secondarySpan='<span class="eur-price">' + secondaryFormatted + '</span>';
if(primaryCurrency==='EUR'){
$this.after(' ' + secondarySpan);
}else if(eurPosition==='left'){
$this.before(secondarySpan + ' ');
}else{
$this.after(' ' + secondarySpan);
}}
}}
});
}
function processAllPrices(){
processCartItemPrices();
processCartTotals();
processShippingMethods();
processCheckoutBlockShipping();
processCartFees();
$('.widget_shopping_cart .mini_cart_item .quantity').each(function(){
if(!hasEurPrice(this)){
addEurPrice(this);
}});
}
function init(){
processAllPrices();
const observer=new MutationObserver(function(mutations){
var shouldProcess=false;
mutations.forEach(function(mutation){
if(mutation.type==='childList'){
if(mutation.target.querySelector&&(
mutation.target.querySelector('.woocommerce-Price-amount') ||
mutation.target.querySelector('#shipping_method') ||
mutation.target.querySelector('.wc-block-formatted-money-amount') ||
mutation.target.querySelector('.wc-block-components-radio-control__option') ||
mutation.target.id==='shipping_method' ||
mutation.target.classList.contains('woocommerce-shipping-totals') ||
mutation.target.classList.contains('woocommerce-shipping-methods') ||
mutation.target.classList.contains('wc-block-components-shipping-rates-control') ||
mutation.target.classList.contains('wc-block-checkout__shipping-option') ||
mutation.target.classList.contains('wc-block-components-totals-item') ||
mutation.target.classList.contains('wc-block-components-totals-item__value')
)){
shouldProcess=true;
}
if(mutation.addedNodes&&mutation.addedNodes.length > 0){
for (var i=0; i < mutation.addedNodes.length; i++){
var node=mutation.addedNodes[i];
if(node.nodeType===Node.ELEMENT_NODE){
if(node.querySelector&&(
node.querySelector('.woocommerce-Price-amount') ||
node.querySelector('#shipping_method') ||
node.classList.contains('woocommerce-shipping-methods') ||
node.id==='shipping_method'
)){
shouldProcess=true;
break;
}}
}}
}else if(mutation.type==='characterData'){
var target=mutation.target.parentElement;
if(target&&(
target.classList.contains('woocommerce-Price-amount') ||
target.querySelector('.woocommerce-Price-amount')
)){
shouldProcess=true;
}}
});
if(shouldProcess){
setTimeout(function(){
processAllPrices();
setTimeout(processAllPrices, 100);
}, 50);
}});
const containers=document.querySelectorAll('.wp-block-woocommerce-cart, ' +
'.wp-block-woocommerce-checkout, ' +
'.wp-block-woocommerce-mini-cart, ' +
'.widget_shopping_cart, ' +
'.woocommerce-shipping-totals, ' +
'.woocommerce-shipping-methods, ' +
'.wc-block-checkout__shipping-option, ' +
'.wc-block-components-shipping-rates-control, ' +
'.wc-block-components-totals-wrapper, ' +
'.wc-block-components-totals-item, ' +
'#shipping_method'
);
const parentContainers=document.querySelectorAll('.woocommerce-checkout-review-order-table, ' +
'.woocommerce-checkout-review-order, ' +
'.shop_table_responsive, ' +
'.cart_totals'
);
for (const container of containers){
observer.observe(container, {
childList: true,
subtree: true,
characterData: true,
attributes: true,
attributeFilter: ['class', 'data-title']
});
}
for (const parentContainer of parentContainers){
observer.observe(parentContainer, {
childList: true,
subtree: true,
characterData: true
});
}
const forms=document.querySelectorAll('.woocommerce-cart-form, .woocommerce-checkout');
for (const form of forms){
if(form){
observer.observe(form, {
childList: true,
subtree: true,
characterData: true
});
}}
$(document).on('wc-blocks-cart-update wc-blocks-checkout-update', function(){
setTimeout(processAllPrices, 100);
});
$(document).on('change', '.wc-block-components-radio-control__input', function(){
setTimeout(processAllPrices, 150);
});
$(document).on('change', '.wc-block-components-quantity-selector__input', function(){
setTimeout(processAllPrices, 100);
});
$(document).on('click', '.wc-block-components-quantity-selector__button', function(){
setTimeout(processAllPrices, 100);
});
$(document).on('added_to_cart removed_from_cart updated_cart_totals', function(){
setTimeout(processAllPrices, 100);
});
$(document).on('change', 'input[name^="shipping_method"]', function(){
setTimeout(processAllPrices, 100);
});
$(document).on('updated_checkout', function(){
setTimeout(processAllPrices, 150);
});
$(document).on('updated_shipping_method', function(){
setTimeout(processAllPrices, 100);
});
$(document).ajaxComplete(function(event, xhr, settings){
if(settings.url&&(
settings.url.indexOf('wc-ajax=') > -1 ||
settings.url.indexOf('update_order_review') > -1 ||
settings.url.indexOf('get_refreshed_fragments') > -1 ||
settings.url.indexOf('shipping') > -1 ||
settings.url.indexOf('speedy') > -1 ||
settings.url.indexOf('econt') > -1 ||
(settings.data&&typeof settings.data==='string'&&settings.data.indexOf('shipping') > -1)
)){
setTimeout(function(){
processAllPrices();
setTimeout(function(){
if($('#shipping_method .woocommerce-Price-amount').length > 0 &&
$('#shipping_method .eur-price').length===0){
processShippingMethods();
}}, 200);
}, 100);
}});
$(document).on('DOMNodeInserted', '#shipping_method', function(){
setTimeout(function(){
processShippingMethods();
}, 50);
});
if(document.querySelector('.woocommerce-cart, .woocommerce-checkout')){
setInterval(function(){
var needsUpdate=false;
$('#shipping_method li, .woocommerce-shipping-methods li').each(function(){
var $li=$(this);
var $priceSpan=$li.find('.woocommerce-Price-amount');
var $secondarySpan=$li.find('.eur-price');
var labelText=$li.find('label').text();
if($priceSpan.length > 0&&$secondarySpan.length===0 &&
(!labelText||labelText.indexOf(secondaryLabel)===-1)){
var text=$priceSpan.text().trim();
var pricePattern=getPricePattern();
if(text&&text.match(pricePattern)){
needsUpdate=true;
return false;
}}
});
if(needsUpdate){
processAllPrices();
}}, 2000);
}}
$(document).ready(init);
$(window).on('load', processAllPrices);
})(jQuery);