how to add woocommerce cart counter

Solutions on MaxInterview for how to add woocommerce cart counter by the best coders in the world

showing results for - "how to add woocommerce cart counter"
Halima
04 Mar 2020
1<a href="<?php echo wc_get_cart_url() ?>" class="misha-cart">Cart (<?php echo $woocommerce->cart->cart_contents_count ?>)</a>
Camilla
08 Feb 2017
1add_filter( 'woocommerce_add_to_cart_fragments', 'misha_add_to_cart_fragment' );
2 
3function misha_add_to_cart_fragment( $fragments ) {
4 
5	global $woocommerce;
6 
7	$fragments['.misha-cart'] = '<a href="' . wc_get_cart_url() . '" class="misha-cart">Cart (' . $woocommerce->cart->cart_contents_count . ')</a>';
8 	return $fragments;
9 
10 }