Woocommerce Total Item with Ajax

Woocommerce Total Item with Ajax Code Snippet
Share:
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
<div class="header-cart-count"><?php echo WC()->cart->get_cart_contents_count(); ?></div>
add_filter( 'woocommerce_add_to_cart_fragments', 'iconic_cart_count_fragments', 10, 1 );

function iconic_cart_count_fragments( $fragments ) {
    
    $fragments['div.header-cart-count'] = '<div class="header-cart-count">' . WC()->cart->get_cart_contents_count() . '</div>';
    
    return $fragments;
}

Reference : Update Custom Cart Count (or any HTML) after AJAX Add to Cart in WooCommerce

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Article

OpenStreetMap and Leaflet.js
OpenStreetMap is a map of the world, created by people like you and free to use under an open license. […]
Video Code using ACF Video Field
Solution of Jumping Modal Popups
I get this code from my client and also my friend 😊
COMPLETE PACKAGE OF WEBSITE DESIGN & DEVELOPMENT
Digitalizer offers website design & development services for company profiles, online shops, event organizers, educational institutions or other fields. You don't need to think about domains, web hosting / servers, DNS, email, design, development, security and other technical issues. Just prepare your website content, we do the rest.
All website design & development packages include 1 year maintenance!
Free Consultation
Back to top
cross