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

Anchor link to Oxygen Builder Tabs
JS code to create anchor link for Tabs component of Oxygen Builder
Change Video Playing Speed with Javascript
If you want to play html tag "video" slower 80%, you can use this code:
Accordion
Accordion code snippet
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