WooCommerce: Hide Mini-Cart Widget (Dropdown)

Less is more (sometimes). On this website, I’m already forcing max 1 product in the Cart and automatically redirecting users to Checkout upon add to Cart.

As a result, I definitely didn’t need the whole “Mini-Cart Widget Dropdown Content” either. 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!

WooCommerce: Hide the Mini-Cart Widget Dropdown Content

PHP Snippet: Hide Menu Mini-Cart Widget Dropdown @ WooCommerce Header

/**
 * @snippet       Hide Menu Mini-Cart Widget Dropdown Content
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=73060
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.4.3
 */

add_filter( 'woocommerce_widget_cart_is_hidden', '__return_true' );

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

16 thoughts on “WooCommerce: Hide Mini-Cart Widget (Dropdown)

  1. Nice post, but i would like to know the opposite, thats how to show the dropdown containint the mini cart on mouse click

    1. 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!

  2. 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

    1. 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!

  3. 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?

    1. Ask Elementor support please

  4. 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!

    1. Hi Tiffany! I guess that JS script also needs to be dequeued – this should fix your problem 🙂

  5. 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.

    1. 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!

  6. Unable to get this to hide the drop-down in my Avada theme installation. I’m running a child theme.

    1. 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 🙂

  7. 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

    1. 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.

    2. 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

      1. Hey Hans! You can add the cart widget by using this PHP function:

        the_widget( 'WC_Widget_Cart', 'title=' );
        
Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published.