Hide particular category from frontend

Add this code in your activated theme in functions.php file to hide some categories from frontend in wordpress woocommerce. In the below code we hide the uncategorized category from frontend, you can replace this category name with your category name. If you want to exclude some products from frontend in woocommerce. You can see this post: Exclude products by id in shop and category page

add_action( 'woocommerce_product_query', 'cf_custom_pre_get_posts_query' );
function cf_custom_pre_get_posts_query( $q ) {
	$tax_query = (array) $q->get( 'tax_query' );
	$tax_query[] = array(
	'taxonomy' => 'product_cat',
	'field' => 'slug',
	'terms' =>array( 'uncategorized'),
	'operator' => 'NOT IN'
	);
	$q->set( 'tax_query', $tax_query );
}