Looking to hide woocommerce cart on non-shop pages?

themeforest
#1

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?

Ta
Amber

1 Like
#2

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.

2 Likes
#3

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

Tytyty

#4

Hi again,

Just wondering where I might find this information?

.your-shopping-cart-class-or-ID-goes-here

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?

#5

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.

1 Like
#6

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.