Looking to hide woocommerce cart on non-shop pages?

Hi there,
Just wondering if anyone is able to tell me how I can hide the woocommerce cart (top right of my menu bar in my wordpress theme) for all non-shop pages?


1 Like

You can easily do this with CSS. All woocommerce related pages add class “woocommerce” to the body tag, so you can use it with “:not” selector.

Something like this:

body:not(.woocommerce) .your-shopping-cart-class-or-ID-goes-here {
display: none !important;

Hope this helps.


Thank you so much for the help, I will try this asap :slight_smile:


Hi again,

Just wondering where I might find this information?


I can’t seem to find this …sorry, any assistance is greatly appreciated :slight_smile:
The site I am working on is here, it is the BETHEME from TF and I was hoping to hide the cart icon in the menu from all but essential woocommerce pages if possible?

Create an ID or Class and replace it with “your-shopping-cart-class-or-ID-goes-here” then link your class or ID to your shopping cart selector or container.

For example:

if ID:
body:not(.woocommerce) #class_name {
display: none !important;

if Class:
body:not(.woocommerce) .class_name {
display: none !important;

This requires some CSS customization. Make sure to create a child-theme before implementing this change otherwise after theme update, your changes will be gone.


That solutions works awesome, hides the little cart icon on all pages not shop related :slight_smile: Thanks heaps guys really appreciate your time helping me.