This is the function that you need to call and pass the product type that's registered in WordPress (by WooCommerce). It's 'product'.

$total_products_obj = wp_count_posts( 'product' );

 

This function call returns an object with multiple properties and you can decide what you need. The total number of published products or those saved as draft.

object(stdClass)#1011 (19) {
  ["publish"]=>
  string(2) "13"
  ["future"]=>
  int(0)
  ["draft"]=>
  int(0)
  ["pending"]=>
  int(0)
  ["private"]=>
  int(0)
  ["trash"]=>
  int(0)
  ["auto-draft"]=>
  int(0)
  ["inherit"]=>
  int(0)
  ["request-pending"]=>
  int(0)
  ["request-confirmed"]=>
  int(0)
  ["request-failed"]=>
  int(0)
  ["request-completed"]=>
  int(0)
  ["wc-pending"]=>
  int(0)
  ["wc-processing"]=>
  int(0)
  ["wc-on-hold"]=>
  int(0)
  ["wc-completed"]=>
  int(0)
  ["wc-cancelled"]=>
  int(0)
  ["wc-refunded"]=>
  int(0)
  ["wc-failed"]=>
  int(0)
}

 

To get the number of published products you need to access this property: $total_products_obj->publish

To get the number of draft products you need to access this property: $total_products_obj->draft