add_action( 'hook_count_all_products', 'my_count_all_products');
function my_count_all_products() {
$args = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1 );
$products = new WP_Query( $args );
echo '' . $products->found_posts . '';
}