Automattic\WooCommerce\Internal\Admin

SiteHealth::needs_shipping_methodsprivateWC 1.0

Determine whether shipping is enabled but no methods are configured.

Method of the class: SiteHealth{}

No Hooks.

Returns

true|false.

Usage

// private - for code of main (parent) class only
$result = $this->needs_shipping_methods();

SiteHealth::needs_shipping_methods() code WC 11.0.0

private function needs_shipping_methods() {
	if ( ! wc_shipping_enabled() ) {
		return false;
	}

	$product_count = wc_get_container()->get( ProductUtil::class )->get_counts_for_type( 'product' );

	return ( $product_count[ ProductStatus::PUBLISH ] ?? 0 ) > 0 && 0 === wc_get_shipping_method_count();
}