How to remove the empty cart number in Astra theme

astra theme templates

With the Astra theme header builder, you can add a cart to your menus, which by default will show inside the cart icon the number of products added to the cart, and so far so good…

astra empty cart showing a 0

But it turns out that the cart always displays the number of items, even if it is empty, showing a zero (0).

If you want that when the cart is empty Astra does not show that zero, that it shows the cart really empty, you can easily achieve this by adding this filter:

/* Remove number when cart is empty */
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;
}Code language: PHP (php)

Now the cart, when there are no products added, will be shown really empty, without any numbers, showing only numbers when there are products in the cart.

astra empty cart not showing any number

Where do I add this code?

In this case, the ideal way is to add the code at the end of the functions.php file of your Astra child theme, as I explain in this tutorial:

WordPress guide: How and where to paste PHP, JS, CSS codes and functions

How useful was this post?

Click on a smiley to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Follow us on social media!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top