How To Hide Quantity Number When the Woocommerce Cart Is Empty?

No results found. Try again with different words?

Search must be at least 3 characters.

How To Hide Quantity Number When the Woocommerce Cart Is Empty?

Astra’s Header Footer Builder comes with the WooCommerce Cart element that allows you to add the mini-cart to your header. By default, the mini-cart displays a number of items added to the cart together with the icon.

The mini-cart will show the number “0” until the first product is added to the cart. 

WooCommerce Mini-Cart

In case you would like to hide this number, you can do it by adding a custom code (filter). Adding the filter will hide the number of products while the mini-cart is empty.

Filter to Hide the Quantity Number When Cart I Empty

To do this, you would need to add the following filter to the functions.php file of your Child Theme:

add_filter('astra_woo_header_cart_total', 'remove_cart_count');
function remove_cart_count( $default){
	if(0 == WC()->cart->get_cart_contents_count()){
		return false;
		return $default;

If you don’t have your Child Theme installed, please check this article on how to do it.

If you are not sure how to add this code, please check this article

Was this article helpful?
Did not find a solution? We are here to help you succeed.

Related Docs

Scroll to Top
Now choose your preferred
page builder addon
Choose your preferred page builder addon

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Download Free Astra Theme - Modal Popup Form