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        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @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 (before "?>" if you have it). 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+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a 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.

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

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

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

  3. 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: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.