Skip to content
jQuery(document).ready(function($) {
if ($('.elementor-menu-cart__toggle_button').length === 0) return;
// Wipe Woo fragments storage/cookies keys to avoid mismatch/expired throws
if (typeof wc_cart_fragments_params !== 'undefined') {
sessionStorage.removeItem(wc_cart_fragments_params.fragment_name);
sessionStorage.removeItem(wc_cart_fragments_params.cart_hash_key);
localStorage.removeItem(wc_cart_fragments_params.cart_hash_key);
sessionStorage.removeItem('wc_cart_created');
// Optional: Force cookie clear if mismatch (careful - logs out cart)
document.cookie = "woocommerce_cart_hash=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
}
// Trigger refresh after short delay for initial render
setTimeout(function() {
$(document.body).trigger('wc_fragment_refresh');
$(document.body).trigger('wc_update_cart');
}, 600); // 0.6s – shorter now that stale data is cleared; adjust if needed
});
function dequeue_wc_fragments_for_stability() {
wp_dequeue_script( 'wc-cart-fragments' );
}
add_action( 'wp_enqueue_scripts', 'dequeue_wc_fragments_for_stability', 999 );