Hide shopping cart in header when empty
-
Hi, Is there anyway to hide the shopping cart in the header of my page if the cart is empty? When someone add’s a item it should then it should be there but not before that.
Thanks.
-
Hi,
I’m using Storefront child theme and hide shopping cart in header when empty adding this code in functions.php of my chlid theme://Remove car from the storefront_header hook when empty add_action( 'storefront_header', 'remove_storefront_header_cart', 50 ); function remove_storefront_header_cart () { global $woocommerce; if ($woocommerce->cart->cart_contents_count == 0) { remove_action( 'storefront_header', 'storefront_header_cart', 60 );} }
You must adapt to your theme hooks and functions.
I hope it helps you,
Anawhat line of code does this go on
I would like to know where this code goes as well. It seems this should be a simple solution and not have to have an additional plugin. Please, help!
Tried using that code in a few different ways and it didn’t work for me either. Would be nice to hide the cart, Im using a Storefront-Child Theme. If someone could help that would be great
So this is what I did to solve the hide cart when empty issue in Woocommerce.
Disabled the cart all together in the menu. Then on the store page, in the sidebar, I placed the Woocommerce cart widget. It gives the option of “hide cart when empty”. I tested it with my “return to shop” button through plugindistrict and it works. I was able to place the widget in the sidebars of the pages I wanted it to show. Much easier than messing with code. Hope this helps!That doesnt work for me either. Anything i have tried has not removed the $0.00, 0 items, and Cart Icon from within my header. https://www.oztourguide.com if you need to see it. (Storefront-Child Theme)
Im using external code as my products and booking forms, which in turn means that i dont need the woocommerce basket/cart at all. If someone could help me fix this it would be greatly appreciated!!
Hi oztourguide,
What you are asking for is a bit different than what the thread is about. However, I did check out your site and see what you are talking about. I have Avada theme which is not the same but hoping what I found helps you.
Make sure your WP, Theme and Woocommerce up to date.
Go to your dashboard in WP, scroll down to “appearance”
Under Appearance there should be Theme Options
Open Theme Options and there should be a long list of items, “General, site width, header, etc”.
Scroll down until you find “Woocommerce” and open it. There should be a another long list of items just for Woocommerce.
Scroll down again and you will see “Show Woocommerce Cart Icon in Secondary Menu, Show Woocommerce Cart Icon in Main Menu, Woocommerce My Account Link in Secondary Menu, Woocommerce Account Link in Main Menus” Make sure they are all unchecked and see if it removes the icon.
If this does not work, I can ask my web guy if he used a special code to remove mine and pass it along.
Also, another option. I have had help from a web person (not mine) regarding Woocommerce. His name is Rodolfo Melorgi. I found him online and he is great in answering Woocommerce issues on his blog. And if all else fails, you can hire him.
Hi Jilliank
Thanks so much for taking the time to help.
I have had a good look around and your menu options must be different due to a different Theme. I think this specific problem of mine will need the use of some hard code maybe.If you do get a chance to ask your guy that would be amazing, but if not its all good. We all have our own busy stuff going on and im sure i’ll find out a way eventually.
Hi Oztourguide,
Talked with my web guy and he said he simply unchecked the cart from the menu in the dashboard. For some reason I remember him using a code but that could have been before the latest theme upgrade.Did you see this in support? https://www.ads-software.com/support/topic/remove-cart-icon-from-menu-bar?replies=4
https://colorlib.com/wp/forums/topic/woocommerce-cart-in-navigation/
I did a bit of research and found that Storefront theme is a Wootheme? If so, you should be able to get support from them, since you are a paying client.
Or, if you are still stuck after reading the above links and can’t get help from Woothemes, consider contacting Rodolfo Megoli. He is a Woocommerce expert. He doesn’t charge much and is really quick with responding. I have used his services twice for Woocommerce issues when I and my web guy were stuck. https://businessbloomer.com/ecommerce-woocommerce-web-design/web-design-quote/
I know how frustrating it is to have an issue with website and spend much time trying to figure it out. There is always a solution, just keep at it! Best wishes
Hi Jilliank
The tales of the ever invincible shopping cart continue.
I thought after going through those links you posted i had it figured out. But it seems no matter how or where i use the recommended code, from each support forum i have come across, it doesnt budge. Bit frustrating like you said but there is always a way.
Think it may be a job for some hard code done by some hired help. I suspect it could be a confliction between a plug-in that i currently need to use or something along those lines. I’ll definitely look into contacting Rodolfo about the issue.
Once again thanks for taking the time, its much appreciated.
- The topic ‘Hide shopping cart in header when empty’ is closed to new replies.