Do you want to change the visibility of a product in your WooCommerce store? You might want to change the visibility of a single product in your WooCommerce store, but you do not know how to go about it. This post aims to show you exactly how to do that.
WooCommerce Product Visibility
There are scenarios you may need to hide a product from your WooCommerce store. Some of them include:
- If products are only available to certain customers, the products need to be hidden from the public.
- If products are no longer sold but may be sold again in the future.
- If you offer service-based products, they require to be manually added to a sales representative quote.
There are many other scenarios, but these stand out. To start, I will share how to hide a single WooCommerce product from the front end using the built-in WooCommerce and WordPress functionality. Moreover, I will share how you can hide hidden products from WooCommerce cart, checkout, order, and emails.
Steps to Hide a WooCommerce Product (Single Product)
- Log into your WordPress site and access the Dashboard as the admin user.
- From the Dashboard menu, click on Products and select the product you would like to hide from the site.
- Click on the Product title and go to the edit page, as shown below:
- On the right-hand side, you will see the familiar “Publish” meta box. It allows you to set publishing options and publish your posts, products, or pages. There is an option there called “Catalog visibility.” Click on the Edit link next to it. You will be presented with a list of options for the visibility of the Product on the front end.
- Select the Hidden option
- Click on the Update button, and the product will completely disappear from the front end of your WooCommerce Store.
However, it is worth mentioning that even though hidden products do not show on the shop and category pages, they appear on the cart if they are added to the cart “programmatically.” Therefore, we need to hide hidden products on the cart, checkout, order received, and emails. This is a challenging task, but as usual, I have a solution for this.
Steps to Hide Hidden Products from WooCommerce Cart, Checkout, Order, and Emails
Here are the steps that you need to follow:
- Log into your WordPress site and access the Dashboard as the admin user.
- From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file to add the function to hide products from the WooCommerce cart, checkout, order received, and emails.
- Add the following code to the function.php file:
/** * Hide Hidden Products from Cart, Checkout, Order - WooCommerce */ add_filter( 'woocommerce_cart_item_visible', 'njengah_hide_hidden_product_from_cart' , 10, 3 ); add_filter( 'woocommerce_widget_cart_item_visible', 'njengah_hide_hidden_product_from_cart', 10, 3 ); add_filter( 'woocommerce_checkout_cart_item_visible', 'njengah_hide_hidden_product_from_cart', 10, 3 ); add_filter( 'woocommerce_order_item_visible', 'njengah_hide_hidden_product_from_order_woo333', 10, 2 ); function njengah_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 njengah_hide_hidden_product_from_order_woo333( $visible, $order_item ) { $product = $order_item->get_product(); if ( $product->get_catalog_visibility() == 'hidden' ) { $visible = false; } return $visible; }
- Remember to save the changes you make.
Conclusion
In summary, this post illustrates how you can change product visibility in your WooCommerce store. Additionally, I have highlighted some of the scenarios that might push you to hide a product from your store. However, you need to know that hiding the product is not enough, as it can be added to the cart programmatically. I have shared a PHP snippet that you can use to hide the product from the cart, checkout, order received, and emails.
Similar Articles
- How to Hide Tags In Storefront Theme WooCommerce
- How to Hide Mobile Footer From Storefront WooCommerce
- How to Turn off Next Product Tabs In WooCommerce Storefront
- How to Remove Cart Page WooCommerce Storefront Theme
- How to Change Storefront Theme Order of Products
- How to Customize Storefront Checkout Page
- How to Change Storefront Theme Product Page Tabs Colors
- How to Remove or Rename Sale Badge WooCommerce Storefront
- How to Remove, Rename and Add Storefront Sorting Options
- How to Hide Product Prices Based on User Role Storefront
Comments are closed.