WC_Install::is_new_installpublic staticWC 3.2.0

Is this a brand new WC install?

A brand-new installation has no version yet. Also treat empty installations as 'new'.

Method of the class: WC_Install{}

No Hooks.

Returns

true|false.

Usage

$result = WC_Install::is_new_install();

Changelog

Since 3.2.0 Introduced.
Since 11.0.0 returns false early for stores that are already live or have completed onboarding.

WC_Install::is_new_install() code WC 11.0.0

public static function is_new_install() {
	// Performance note: woocommerce_version is absent before the very first install routine completes.
	if ( false === get_option( 'woocommerce_version' ) ) {
		return true;
	}

	// Performance note: verify if the store is live. This option is auto-loaded, and verification is essentially free.
	if ( 'no' === get_option( 'woocommerce_coming_soon', 'yes' ) ) {
		return false;
	}

	// Performance note: verify if onboarding is complete. This option is auto-loaded, and verification is essentially free.
	if ( in_array( 'setup', (array) get_option( 'woocommerce_task_list_completed_lists', array() ), true ) ) {
		return false;
	}

	// Performance note: this is the original fallback. The store setup is incomplete, and even with a cold cache, we do not anticipate performance issues.
	return -1 === wc_get_page_id( 'shop' ) && 0 === array_sum( wc_get_container()->get( ProductUtil::class )->get_counts_for_type( 'product' ) );
}