Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks

Products::has_products()public staticWC 1.0

Check if the store has any published products.

Method of the class: Products{}

No Hooks.

Return

true|false.

Usage

$result = Products::has_products();

Products::has_products() code WC 7.1.1

public static function has_products() {
	$product_query = new \WC_Product_Query(
		array(
			'limit'  => 1,
			'return' => 'ids',
			'status' => array( 'publish' ),
		)
	);
	$products      = $product_query->get_products();

	return count( $products ) !== 0;
}