Less is more (sometimes). On this same website, I’m already forcing max 1 product in the Cart and automatically redirecting users to Checkout upon add to Cart. On top of that, I’ve disabled WooCommerce cart fragments for performance reasons.
As a result, I definitely don’t need the whole “Mini-Cart Widget Dropdown Content”. To test, try to “hover” onto the shopping cart icon on the top right, and you’ll notice there is no cart dropdown.
Well, this is how it’s done – I love when a complex thing is fixed with one simple line of PHP!
PHP Snippet: Hide Menu Mini-Cart Widget Dropdown @ WooCommerce Header
/**
* @snippet Remove WooCommerce Mini-Cart
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 6
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_widget_cart_is_hidden', '__return_true' );
Nice post, but i would like to know the opposite, thats how to show the dropdown containint the mini cart on mouse click
Hi Ronald, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi,
Used your code on my website, but my whole WC Cart was hidden. I want to leave Menu Cart Icon and if someone will click on it, it will take him to the Cart Page. So I want to hide just WC Menu Cart Dropdown (Mini Cart). Can you help me with that?
Regards,
Danylo
Hi Danylo, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Hi, I have a problem. I’m editing a store through Elementor Pro, and when clicking on the “menu cart” widget, I would like it to open the checkout page directly, instead of opening a preview sidebar, could you help me?
Ask Elementor support please
Thanks for this snippet Rodofo!
It works a treat for hiding the mini-cart widget. I think it’s possibly creating a browser error, though,
Uncaught TypeError: Cannot read property ‘getBoundingClientRect’ of null
at HTMLUListElement. (header-cart.min.js:1)
I tested for browser errors with and without the snippet and it seems to be related as the mini-cart is made null.
I appreciate all you’re doing to help others!
Hi Tiffany! I guess that JS script also needs to be dequeued – this should fix your problem 🙂
Hi Rodolfo!
Thank you for this amazing post! 😉
May I ask you a question? How to edit a button in the mini cart widget (ie checkout > Secure checkout) ?
Thank you Rodolfo.
Hello Stephane, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!
Unable to get this to hide the drop-down in my Avada theme installation. I’m running a child theme.
Hello Rob, thanks for your comment! Avada has its own custom WooCommerce templates, so probably this function will need to be edited for that reason. Hope this helps 🙂
Hi Rodolfo,
Thanks for the snippet. Is this snippet for use in a specific theme? It looks like storefront, but you haven’t specified.
Thanks,
Hans
Hey Hans, thanks for your comment! This is for all themes as it’s a default WooCommerce functionality. Some non-WooCommerce themes don’t show the Cart Widget in the navigation bar though, so it depends, yes 🙂 It works on Storefront for sure.
Alright, thanks. I use genesis framework, so those themes don’t show the the cart widget in the navigation, although some basic woocommerce support is build-in. Do you have a snippet to add, or is the use of a plugin advised?
Hans
Hey Hans! You can add the cart widget by using this PHP function: