jQuery(document).ready(function(){
jQuery(document.body).on('update_checkout updated_checkout applied_coupon_in_checkout removed_coupon_in_checkout checkout_error', function(){
if(jQuery('.g-recaptcha').length > 0){
if(typeof grecaptcha!=="undefined"&&typeof grecaptcha.reset==="function"){
var count=0;
jQuery(".g-recaptcha").each(function (){
grecaptcha.reset(count);
count++;
});
}}
});
});
(function(){
document.addEventListener('DOMContentLoaded', function(){
window.rcfwcRecaptchaCallback=function(token){
try {
if(typeof wp!=='undefined'&&wp.data){
wp.data.dispatch('wc/store/checkout').__internalSetExtensionData('rcfwc', { token: token });
}} catch (e){}};
window.rcfwcRecaptchaExpired=function(){
try {
if(typeof wp!=='undefined'&&wp.data){
wp.data.dispatch('wc/store/checkout').__internalSetExtensionData('rcfwc', { token: '' });
}} catch (e){}};
if(typeof wp!=='undefined'&&wp.data){
var unsubscribe=wp.data.subscribe(function(){
var el=document.getElementById('g-recaptcha-woo-checkout');
if(!el){
return;
}
if(el.innerHTML&&el.innerHTML.trim()!==''){
unsubscribe&&unsubscribe();
return;
}
if(typeof grecaptcha!=='undefined'&&typeof grecaptcha.render==='function'){
try {
grecaptcha.render(el, {
sitekey: el.getAttribute('data-sitekey'),
callback: rcfwcRecaptchaCallback,
'expired-callback': rcfwcRecaptchaExpired
});
} catch (e){
}
unsubscribe&&unsubscribe();
}}, 'wc/store/cart');
}});
})();