function checkCartAbandonment() {
fetch('/wp-admin/admin-ajax.php', {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: 'action=check_cart_items'
})
.then(response => {
if (!response.ok) {
throw new Error('AJAX request failed: ' + response.statusText);
}
return response.json();
})
.then(data => {
const hasItems = data && data.hasItems; // Check if data exists
const hasShown = sessionStorage.getItem('cartAbandonmentShown');
if (hasItems && !window.location.pathname.includes('/cart') && !window.location.pathname.includes('/checkout') && !hasShown) {
showPopup('cart-abandonment-popup');
sessionStorage.setItem('cartAbandonmentShown', 'true');
}
})
.catch(error => {
console.error('Error in checkCartAbandonment:', error);
// Prevent the error from breaking the page
});
}
Warning: Cannot modify header information - headers already sent by (output started at /home/sarkarhealings/public_html/wp-content/themes/kadence-child/functions.php:437) in /home/sarkarhealings/public_html/wp-includes/pluggable.php on line 1450
Warning: Cannot modify header information - headers already sent by (output started at /home/sarkarhealings/public_html/wp-content/themes/kadence-child/functions.php:437) in /home/sarkarhealings/public_html/wp-includes/pluggable.php on line 1453