D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
raptqcnr
/
www
/
wp-content
/
themes
/
woodmart
/
js
/
scripts
/
wc
/
Filename :
freeGiftsTable.min.js
back
Copy
function updateGiftsTable(){var o,e,d=document.querySelector(".wd-fg");d&&(o=!!d.dataset.hasOwnProperty("settings")&&JSON.parse(d.dataset.settings),(e=d.querySelector(".wd-loader-overlay"))&&e.classList.add("wd-loading"),jQuery.ajax({url:woodmart_settings.ajaxurl,data:{action:"woodmart_update_gifts_table"},method:"POST",success:function(e){var t;e&&d&&e.hasOwnProperty("html")&&((t=document.createElement("div")).innerHTML=e.html,o&&"no"===o.show_title&&(e=t.querySelector(".wd-el-title"))&&e.remove(),0===(childNodes=t.childNodes).length?d.classList.add("wd-hide"):d.classList.remove("wd-hide"),d.replaceChildren(...childNodes))},error:function(){console.log("ajax update gifts table error")},complete:function(){e&&e.classList.remove("wd-loading")}}))}jQuery.each(["frontend/element_ready/wd_cart_table.default"],function(e,t){woodmartThemeModule.wdElementorAddAction(t,function(e){woodmartThemeModule.addGiftProduct()})}),jQuery(document.body).on("updated_cart_totals",updateGiftsTable),jQuery(document.body).on("updated_checkout",updateGiftsTable),woodmartThemeModule.addGiftProduct=function(){var d=!!document.querySelector(".woocommerce-checkout"),e=document.querySelector(".site-content .woocommerce");e&&e.addEventListener("click",function(e){var t,o=e.target.closest(".wd-add-gift-product");o&&(e.preventDefault(),t=o.closest(".wd-fg").querySelector(".wd-loader-overlay"),e=o.dataset.productId,o.classList.contains("wd-disabled")||(t.classList.add("wd-loading"),jQuery.ajax({url:woodmart_settings.ajaxurl,data:{action:"woodmart_add_gift_product",product_id:e,security:o.dataset.security,is_checkout:d?"1":"0"},method:"POST",success:function(e){e&&(triggerEvent=d?"update_checkout":"wc_update_cart",jQuery(document.body).trigger(triggerEvent))},error:function(){console.log("ajax adding gift to cart error")},complete:function(){t.classList.remove("wd-loading")}})))})},window.addEventListener("load",function(){woodmartThemeModule.addGiftProduct()});