Website Building » WooCommerce » How Do I Hide Cart in WooCommerce?

How Do I Hide Cart in WooCommerce?

Last updated on January 15, 2023 @ 11:45 am

Assuming you want to hide the cart icon in the header:

In WooCommerce, there are two ways to hide the cart. One is to disable it completely, and the other is to hide it on specific pages.

To disable the cart completely, you need to go to WooCommerce > Settings > Advanced. From there, you will find the Disable Cart setting under the Misc section. Simply check the box and save your changes.

If you only want to hide the cart on specific pages, then you can do so by using a plugin or by adding some code to your theme’s functions.php file.

Using a plugin is the easiest way to achieve this. There are a few plugins that can do this, but we recommend using Hide My WP. It’s a free plugin that does a great job at hiding your site from attackers.

To use Hide My WP, simply install and activate the plugin. Once activated, go to Settings > Reading and scroll down to the bottom of the page.

There you will find an option to hide the cart on specific pages. Simply check the boxes next to the pages you want to hide the cart on and save your changes.

Adding code to your theme’s functions.php file is a bit more complicated, but it’s still doable. First, you need to find your theme’s functions.

If you’re using a child theme, then it will be located in your child theme’s directory. If not, then it will be located in your main WordPress directory.

Once you have found your functions.php file, open it in a text editor and add the following code:

add_filter( 'woocommerce_hide_cart_on_specific_pages', '__return_true' );

This code will hide the cart on all pages except for the shop page and product pages. If you want to hide the cart on specific pages, then you will need to replace ‘__return_true’ with an array of page ids. For example:

add_filter( 'woocommerce_hide_cart_on_specific_pages', 'my_custom_function' );
function my_custom_function( $pages ) {
$pages = array( 1, 2, 3 ); // Add page ids here

return $pages;
}
PRO TIP: If you are considering hiding your WooCommerce cart, be aware that this could have negative consequences for your business. Your cart is an important part of the user experience on your website and hiding it could make it more difficult for customers to purchase items from you. Additionally, hiding your cart could also impact your search engine rankings, as it may be seen as a sign that your website is not user-friendly.
Madison Geldart

Madison Geldart

Cloud infrastructure engineer and tech mess solver.