Auto Update Cart counter

add_filter('add_to_cart_custom_fragments', 'woocommerce_header_add_to_cart_custom_fragment');
function woocommerce_header_add_to_cart_custom_fragment( $cart_fragments ) {
global $woocommerce;
ob_start();
?>
<a href="<?php echo $cart_page_url; ?>" class="anchor_button7">
		<img src="<?php echo get_template_directory_uri(); ?>/img/svg/shopping-cart_2.svg" alt="">
		<span>Cart</span>
		<span class="item-count cart-item-count">
				<?php
				// echo WC()->cart->get_cart_contents_count();
				echo sprintf(_n('%d item', '%d ', $woocommerce->cart->cart_contents_count, 'woothemes'),
				$woocommerce->cart->cart_contents_count);?>
		</span>
		<span><?php echo $woocommerce->cart->get_cart_total(); ?></span>
</a>

<?php
$cart_fragments['a.anchor_button7'] = ob_get_clean();
return $cart_fragments;
}

Based on this solution → I tried that on the top of the header my cart Items should auto increase, but that is not happening here → Live Link

How can I troubleshoot?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.