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?

Sidebar Image

Did not find a solution? We are here to help you succeed.

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_action('wp_footer', 'hide_cart');
    function hide_cart() {
        if(WC()->cart->get_cart_contents_count() == 0)
        echo '<style type="text/css">.ast-site-header-cart .ast-addon-cart-wrap i.astra-icon:after{display:none}</style>';
    }
add_filter( 'woocommerce_product_categories_widget_args', 'woo_product_cat_widget_args' );

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?
Sidebar Image

Did not find a solution? We are here to help you succeed.

Related Docs

Join 1,653,898+ Happy Site Owners Using Astra

Whether you are a beginner, small business owner, or professional web developer, Astra provides all the tools you need to easily build your beautiful WordPress website.

Download is Just A Click Away!

Membership Retention Checklist Download

REWIND

YEAR IN REVIEW

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
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