D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
raptqcnr
/
www
/
wp-content
/
themes
/
woodmart
/
js
/
scripts
/
wc
/
Filename :
abandonedCart.min.js
back
Copy
woodmartThemeModule.abandonedCart=function(){var t,e,o=function(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)},r=function(){var e;return"no"===woodmart_settings.abandoned_cart_needs_privacy||(e=document.querySelector("#wd-data-consent"))&&e.checked};(t=document.querySelector("#billing_email"))&&((e=document.querySelector("#wd-data-consent"))&&e.addEventListener("change",function(e){e.stopPropagation(),e.currentTarget.checked&&t.value.length&&o(t.value)&&(e=new Event("change"),t.dispatchEvent(e))}),t.addEventListener("change",function(e){var t,n,a,e=e.target.value;r()&&o(e)&&(t=document.querySelector("#billing_first_name"),n=document.querySelector("#billing_last_name"),a=document.querySelector("#billing_phone"),jQuery.ajax({url:woodmart_settings.ajaxurl,data:{action:"woodmart_recover_guest_cart",security:woodmart_settings.abandoned_cart_security,email:e,phone:a?a.value:"",first_name:t?t.value:"",last_name:n?n.value:"",currency:woodmart_settings.abandoned_cart_currency,language:woodmart_settings.abandoned_cart_language},method:"POST",error:function(){console.log("Ajax error of capturing the abandoned basket of the guest")}}))}))},woodmartThemeModule.showPrivecyCheckbox=function(){var e=document.querySelector(".wd-data-consent"),t=document.querySelector("#billing_email_field");"no"!==woodmart_settings.abandoned_cart_needs_privacy&&e&&t&&(t.appendChild(e),e.classList.remove("wd-hide"))},woodmartThemeModule.showPrivecyCheckbox(),window.addEventListener("load",function(){woodmartThemeModule.abandonedCart()});