WooCommerce: Hide Hidden Products From Cart, Order, Emails

While working on a workaround for a client, I had to hide a hidden product from the cart, checkout, order received and emails. Hidden products already don’t show on the shop and category pages, but they do show on the cart if they’re added to cart “programmatically”.

A tough task, but as usual here I come with the solution πŸ™‚

First, make your WooCommerce product hidden!
The wanted result: hide Hidden Products from the Cart (and also Checkout, Order Received and Emails!)

WooCommerce PHP Snippet: Hide Hidden Products from WooCommerce Cart, Checkout, Order, Emails

 * @snippet       Hide Hidden Products from Cart, Checkout, Order - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=21936
 * @author        Rodolfo Melogli
 * @testedwith    WooCommerce 3.4.5
add_filter( 'woocommerce_cart_item_visible', 'bbloomer_hide_hidden_product_from_cart' , 10, 3 );
add_filter( 'woocommerce_widget_cart_item_visible', 'bbloomer_hide_hidden_product_from_cart', 10, 3 );
add_filter( 'woocommerce_checkout_cart_item_visible', 'bbloomer_hide_hidden_product_from_cart', 10, 3 );
add_filter( 'woocommerce_order_item_visible', 'bbloomer_hide_hidden_product_from_order_woo333', 10, 2 );
function bbloomer_hide_hidden_product_from_cart( $visible, $cart_item, $cart_item_key ) {
	$product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );
	if ( $product->get_catalog_visibility() == 'hidden' ) {
        $visible = false;
    return $visible;
function bbloomer_hide_hidden_product_from_order_woo333( $visible, $order_item ) {
	$product = $order_item->get_product();
	if ( $product->get_catalog_visibility() == 'hidden' ) {
        $visible = false;
    return $visible;

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. You can start learning how to customize WooCommerce without unnecessary plugins. Watch me code and learn by example!

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

22 thoughts on “WooCommerce: Hide Hidden Products From Cart, Order, Emails

  1. Not working 3/1/2020. Hidden product is hidden as is entire cart content.

    Please advise. Latest wordpress release

    1. Hi, thanks for your comment! I just tested this again with Storefront theme and it works perfectly. Maybe your theme (or another plugin) is messing/conflicting with my snippet?

      To troubleshoot, disable all plugins but WooCommerce and also switch temporarily to “Twentyseventeen” theme (load the snippet there in functions.php) – does it work? If yes, you have a problem with your current theme or one of the plugins.

      Hope this helps!


  2. Hi, thanks a lot for this code!
    However, the mini cart on top right seems not to update correctly in my case.
    Should it work for the mini cart as well?
    I dont talk about lowering the item count, just hiding the items in mini cart.

    1. Hello Meena, correct, this snippet does not work with the mini cart. You need to add another hook trigger for hook = “woocommerce_widget_cart_item_visible” for that. Hope this helps

  3. Nice code, but i dont want to hide any product since am using [product_page id ="8080"] to display specific product on the front end, however i want to allow users to purchase this product but i dont want it listed in the orders section in my account orders page, i want only to hide some specific ordered Products from showing on the my orders page.

    1. hi Chris, 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!

  4. This works great! Thank you so much.

    I need one thing to make this complete. Currently, hidden products show up in the menu cart number indicator.

    Would you please help me hide hidden products from this number indicator? I need this number indicator for my store.

    Thank you!

  5. Just an FYI – Be aware of this code!
    We added it to our site and it caused all new orders to duplicate 4-5 times and customers got charged for every duplicated order. A nightmare!
    We love this site and all the snippets are great and never had an issue until now.
    It could just be a conflict on our end, but just be ware.


    1. Thanks Miguel πŸ™‚ This snippet does not duplicate orders, so yes this is definitely another sort of conflict. Always test snippets on a development/clone website and never on a live environment. Thank you!

  6. Hi,

    In th latest version of woocommerce, there seems to be an issue with the following code:

    function bbloomer_hide_hidden_product_from_order( $visible, $order_item ) {
    if ( $order_item->get_catalog_visibility() == 'hidden' ) {
            $visible = false;
        return $visible;

    The order doesn’t go through to the success/thank you page, email notification is not sent to the customer/admin. Does the code hide the HIDDEN products on order email as well?

    Unable to verify as the code is not triggering the successful order email.

    1. You’re absolutely right Vinoth πŸ™‚ Snippet has now been updated!

  7. Hi Rodolfo

    I thank you for this HOOK, which has been very useful for me.

    Now, how could I hide just the prices of the order?



    1. Hola Yeorsh, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  8. This is not working on WooCommerce 3.0.7, any ideas on what needs to be updated for it to work?

    I’ve written some custom jQuery to remove or hide the items in Cart and on Order Received screens on the front-end, but of course this doesn’t stop the hidden product from showing up on customer emails and elsewhere as needed.


    1. Ethan, thanks so much for your comment! And yes, you’re right πŸ™‚ Snippet has now been updated – test it out!

  9. I have added this code to my child theme functions.php file but hidden products still show in cart and emails. Is this code still valid for current wordpress and woo commerce versions. Thank you

    1. Hey Rory, thanks for your comment! Yes, it should definitely work πŸ™‚ Can you send me a screenshot of your hidden product “edit page” and also cart and email? Thank you!

      1. Thanks for the quick reply. I did figure out a mistake I had made which blocked this from working. Now resolved. Thank you so much for making this tutorial and supporting your page.

        I do have another question. I noticed when I generate invoices the hidden products show up again only on the invoice. Should this code be blocking that as well? Do you know of additional code to also hide from invoice?

        1. Excellent Rory πŸ™‚ Do you use a particular invoice plugin, or are you referring to the default WooCommerce invoice?

          1. I have been using booster.io for its pdf feature and the pdf invoice is what includes the hidden items.

            1. Hey Rory, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here on the blog. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

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 *