(t=>{if(!t)return;const{currency:e,products:o,purchase:a,add_to_cart:i,eventsToTrack:n}=globalThis._googlesitekit?.wcdata||{},c=n?.includes("add_to_cart"),r=n?.includes("purchase");if(i&&c){const{price:t}=i,o=d(t,e,i);globalThis._googlesitekit?.gtagEvent?.("add_to_cart",o)}if(a&&r){const{id:t,totals:e,items:o,user_data:i}=a,n=d(e.total_price,e.currency_code,o,t,e.shipping_total,e.tax_total);globalThis._googlesitekit?.gtagUserData&&i&&(n.user_data=i),globalThis._googlesitekit?.gtagEvent?.("purchase",n)}const s=t("body");function d(t,e,o){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null;const c={value:u(t),currency:e,items:[]};if(a&&(c.transaction_id=a),"number"==typeof i&&(c.shipping=i),"number"==typeof n&&(c.tax=n),o&&o.length)for(const t of o)c.items.push(l(t));else o&&o.id&&(c.items=[l(o)]);return c}function l(t){const{id:e,name:o,price:a,variation:i,quantity:n,categories:c}=t,r={item_id:e,item_name:o,price:u(a)};if(n&&(r.quantity=n),i&&(r.item_variant=i),c&&c?.length){let t=1;for(const e of c)r[t>1?`item_category${t}`:"item_category"]=e.name,t++}return r}function u(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return parseInt(t,10)/10**e}c&&(s.on("added_to_cart",(t,a,i,n)=>{if(!n?.jquery)return;const c=parseInt(n.data("product_id"),10);if(!c)return;const r=o?.find(t=>t?.id===c)||{},{price:s}=r,l=d(s,e,r);globalThis._googlesitekit?.gtagEvent?.("add_to_cart",l)}),t(".products-block-post-template .product, .wc-block-product-template .product").each(function(){const a=t(this),i=parseInt(a.find("[data-product_id]").attr("data-product_id"),10);i&&a.on("click",a=>{const n=t(a.target).closest(".wc-block-components-product-button [data-product_id]");if(!n.length||!n.hasClass("add_to_cart_button")||n.hasClass("product_type_variable"))return;const c=o?.find(t=>t?.id===i)||{},{price:r}=c,s=d(r,e,c);globalThis._googlesitekit?.gtagEvent?.("add_to_cart",s)})}))})(globalThis.jQuery);
jQuery(document).ready(function ($){
var variable_id=jQuery('[name="product_id"]').val();
var available_ids=[];
var variable_bulk_table="";
function get_table(product_id, updateBulkTable=false){
if(typeof jQuery('.wdp_bulk_table_content').attr('data-available-ids')!=='undefined'){
available_ids=JSON.parse(jQuery('.wdp_bulk_table_content').attr('data-available-ids'));
}
if(available_ids.indexOf(parseInt(product_id))===-1){
return;
}
if(product_id===variable_id&&variable_bulk_table&&!updateBulkTable){
jQuery('.wdp_bulk_table_content').html(variable_bulk_table)
return true;
}
let attributes={};
jQuery('form.variations_form[data-product_id=' + variable_id + '] select').each(function (index, item){
if(jQuery(item).attr("data-attribute_name")){
attributes[jQuery(item).attr("data-attribute_name")]=jQuery(this).val();
}});
var data={
action: 'get_table_with_product_bulk_table',
product_id: parseInt(product_id),
attributes: attributes,
...jQuery('form.cart').triggerHandler('wdp_get_custom_data')
};
return jQuery.ajax({
url: script_data.ajaxurl,
data: data,
dataType: 'json',
type: 'POST',
success: function (response){
if(response.success){
jQuery('.wdp_bulk_table_content').each(function (_, item){
let jQItem=jQuery(item);
let availableIds=JSON.parse(jQItem.attr('data-available-ids'));
if(availableIds.indexOf(parseInt(product_id))===-1){
return;
}
jQItem.html(jQuery(response.data).children()).trigger('update');
});
init_custom_event();
if(product_id===variable_id){
variable_bulk_table=response.data;
}}else{
get_table(variable_id);
}},
error: function (response){
get_table(variable_id);
}});
}
function init_custom_event(){
jQuery('.wdp_bulk_table_content').on('get_table', function (e, $obj_id){
if(typeof $obj_id==='undefined'||!$obj_id){
get_table(variable_id);
}else{
get_table($obj_id);
}});
}
function init_events(){
if(jQuery('.wdp_bulk_table_content').length > 0){
jQuery('.variations_form').on('found_variation', { variationForm: this },
function (event, variation){
if(typeof variation==='undefined'){
get_table(variable_id);
return true;
}
get_table(variation.variation_id);
return true;
})
.on('click', '.reset_variations',
{ variationForm: this },
function (event, variation){
get_table(variable_id);
return true;
})
.on('reset_data',
function (event){
get_table(variable_id);
return true;
});
jQuery('form.cart').on('adp_found_variation', function (e, { product_id, variation_id}){
get_table(variation_id||product_id, true);
return true;
});
init_custom_event();
}}
if(script_data.js_init_trigger){
$(document).on(script_data.js_init_trigger, function (){
init_events();
});
}
jQuery('form.cart').on('adp_variations_form', function(){
init_events();
});
setTimeout(function (){
jQuery('.variations_form').on("wc_variation_form", function (){
init_events();
})
}, 0);
function watchForQuickView(){
let observer=new MutationObserver(function (mutations){
mutations.forEach(function (mutation){
mutation.addedNodes.forEach(function (node){
if($(node).hasClass('product-lightbox-inner')||$(node).find('.product-lightbox-inner').length){
init_events();
}});
});
});
observer.observe(document.body, { childList: true, subtree: true });
}
watchForQuickView();
});
!function(d,l){"use strict";l.querySelector&&d.addEventListener&&"undefined"!=typeof URL&&(d.wp=d.wp||{},d.wp.receiveEmbedMessage||(d.wp.receiveEmbedMessage=function(e){var t=e.data;if((t||t.secret||t.message||t.value)&&!/[^a-zA-Z0-9]/.test(t.secret)){for(var s,r,n,a=l.querySelectorAll('iframe[data-secret="'+t.secret+'"]'),o=l.querySelectorAll('blockquote[data-secret="'+t.secret+'"]'),c=new RegExp("^https?:$","i"),i=0;i<o.length;i++)o[i].style.display="none";for(i=0;i<a.length;i++)s=a[i],e.source===s.contentWindow&&(s.removeAttribute("style"),"height"===t.message?(1e3<(r=parseInt(t.value,10))?r=1e3:~~r<200&&(r=200),s.height=r):"link"===t.message&&(r=new URL(s.getAttribute("src")),n=new URL(t.value),c.test(n.protocol))&&n.host===r.host&&l.activeElement===s&&(d.top.location.href=t.value))}},d.addEventListener("message",d.wp.receiveEmbedMessage,!1),l.addEventListener("DOMContentLoaded",function(){for(var e,t,s=l.querySelectorAll("iframe.wp-embedded-content"),r=0;r<s.length;r++)(t=(e=s[r]).getAttribute("data-secret"))||(t=Math.random().toString(36).substring(2,12),e.src+="#?secret="+t,e.setAttribute("data-secret",t)),e.contentWindow.postMessage({message:"ready",secret:t},"*")},!1)))}(window,document);
(()=>{const e={statistics:["analytics_storage"],marketing:["ad_storage","ad_user_data","ad_personalization"]},t=()=>{if("function"==typeof wp_has_consent){void 0===window.wp_consent_type&&(window.wp_consent_type="optin");const t={};for(const[n,o]of Object.entries(e))if(""!==consent_api_get_cookie(window.consent_api.cookie_prefix+"_"+n)){const e=wp_has_consent(n)?"granted":"denied";o.forEach(n=>{t[n]=e})}Object.keys(t).length>0&&window.gtag("consent","update",t)}};document.addEventListener("wp_listen_for_consent_change",t=>{const n={},o=e[Object.keys(t.detail)[0]],a="allow"===Object.values(t.detail)[0]?"granted":"denied";void 0!==o&&(o.forEach(e=>{n[e]=a}),Object.keys(n).length>0&&window.gtag("consent","update",n))}),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t):t()})();