Using the below snippet from this forum to hide cart icon when it is empty.
add_filter( 'generate_woocommerce_menu_item_location', 'tu_hide_empty_cart_icon' );
function tu_hide_empty_cart_icon( $location ) {
if ( class_exists( 'WooCommerce' ) && sizeof( WC()->cart->get_cart() ) > 0 ) {
return $location;
}
return 'none';
}
ISSUE: When adding product from single product page, cart icon appears.
But when adding products from shop page or category page. Cart icon appears only after manually refreshing the page.
It would be great if it appears instantly as like single product page.
Thank you.