The default WooCommerce Dashboard Products page (/wp-admin/edit.php?post_type=product page) shows the list of products in a table. Default fields are: Image, SKU, Stock, Price, Categories, Tags, Featured and Date.

Sometimes, these columns are not enough and you need more. For example, you might want to quickly take a look at a product custom field, such as “visibility” (whether the product is hidden or not).

So, here’s the snippet for that. Of course, you can adapt it to show your own custom field, an ACF field or whatever product-related information you require.

Here’s a new WooCommerce Products Table column – in this case it’s the products’s “visibility” status

PHP Snippet: Add Column to Products Table @ WooCommerce Dashboard

/**
 * @snippet       New Products Table Column @ WooCommerce Admin
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.7
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'manage_edit-product_columns', 'bbloomer_admin_products_visibility_column' );

function bbloomer_admin_products_visibility_column( $columns ){
	$columns['visibility'] = 'Visibility';
	return $columns;
}

add_action( 'manage_product_posts_custom_column', 'bbloomer_admin_products_visibility_column_content', 10, 2 );

function bbloomer_admin_products_visibility_column_content( $column, $product_id ){
    if ( $column == 'visibility' ) {
        $product = wc_get_product( $product_id );
		echo $product->get_catalog_visibility();
    }
}
Share:

Leave a Reply