Site logo

Archived topic

Hide cart in secondary menu when its empty

15 replies · Started by Daniele on December 19, 2021

Viewing posts 1–15 of 16

Hello,
I moved the cart in the secondary menu with this filter:

add_filter( 'generate_woocommerce_menu_item_location', 'tu_move_menu_cart_item' );
function tu_move_menu_cart_item() {
return 'secondary';
}

and I would like to hide it if it is empty. How can I accomplish it?

thank you

Hi there,

Try adding this CSS:

span.menu-bar-item.wc-menu-item:not(.has-items) {
    display: none;
}

Hello,
no luck with this,
this is my website: (private information)

Can you link us to a product page where we can see secondary navigation and the navigation cart?

Let me know :)

I checked a few pages but don't see the secondary navigation.

Can you link us to the specific page in question?

Thanks.

Hi,
the navigation is on all the pages of the website (top bar)
You can see the cart top right.

Please check: (private info)

Try this CSS instead:

.secondary-navigation .wc-menu-item:not(.has-items) {
    display: none;
}

it works with important

.secondary-navigation .wc-menu-item:not(.has-items) {
    display: none !important;
}

Glad to hear :)

Hello,
it seems this css is not working anymore, do you have an updated one?

thank you!

Hi there,

can you share a link to the site where we can see the issue?

I have marked the topic unresolved so you can access the Private info fields ( They are auto deleted when a topic is set to resolved ).

The CSS does still work, if i add it via the developers tools, can you clear any plugin caches as i think the CSS has got mixed up amongst the various cached stylesheets

thanks!

This archived topic is closed to new replies.