1. Home
  2. Knowledge Base
  3. WooCommerce Product Table
  4. FAQ

Can I show products in the table which are hidden from my main shop pages?

Some people use WooCommerce Product Table to list products on a dedicated page, while hiding them from their main shop pages. For example, you might like to do this if you're using WooCommerce Product Table to create an internal order form containing different products from your public shop.

Instructions

  1. Add or edit each of the products that you wish to show in the table and hide from the rest of the shop.
  2. On the 'Edit Product' screen, click 'Edit' next to the 'Catalog visibility' option in the Publish section to the top right of the page. Change the visibility to 'Hidden'.
  3. Go to the WooCommerce Product Table settings page and enable the Show hidden products option.
  4. Create product tables via Products → Product Tables and display them on a page using the 'Product Table' Gutenberg block or shortcode. The tables will include your hidden products, even though these products are hidden from your main shop pages.

Code snippet to show hidden products

Occasionally, you may want to disable the global 'Show hidden products' setting and enable hidden products in a specific product table only. You can do this with the following code snippet. It is aimed at developers and you should only use it if you know what you're doing. If you'd like us to implement it for you then you can use our plugin customization service.

/**
* If "Show hidden products" is not active on the general settings and we want to show hidden products on a specific page.
*/
add_filter( 'wc_product_table_query_args', function( $args, $table_query ) {

if ( is_page( 177 ) ) {

$product_visibility_terms = wc_get_product_visibility_term_ids();
$product_visibility_not_in = [ is_search() ? $product_visibility_terms['exclude-from-search'] : $product_visibility_terms['exclude-from-catalog'] ];
if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
$product_visibility_not_in[] = $product_visibility_terms['outofstock'];
}

if ( isset( $args['tax_query'] ) ) {
foreach ( $args['tax_query'] as $key => $args_item ) {
if ( isset( $args_item['taxonomy'] ) && $args_item['taxonomy'] === 'product_visibility' &&
isset( $args_item['field'] ) && $args_item['field'] === 'term_taxonomy_id' &&
isset( $args_item['operator'] ) && $args_item['operator'] === 'NOT IN' &&
isset( $args_item['terms'] ) && $args_item['terms'] === $product_visibility_not_in ) {
unset( $args['tax_query'][ $key ] );
}
}
}
}

return $args;

}, 10, 2 );

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.