Automattic\WooCommerce\Internal\ProductFeed\Mapping

UcpProductMapper::has_catalog_variants │ public │ WC 1.0

Determine whether a product exposes at least one purchasable catalog variant.

Single source of truth for catalog eligibility: a product without variants would violate the catalog product schema (variants requires minItems: 1), so it is excluded from listings and treated as not found on detail lookups. Simple products always qualify; a variable product needs at least one visible variation: enabled and, when the store hides out-of-stock items, in stock. That is the set the storefront and the Store API offer, read through the data store's cached children list.

Method of the class: UcpProductMapper{}

No Hooks.

Returns

bool.

Usage

$UcpProductMapper = new UcpProductMapper();
$UcpProductMapper->has_catalog_variants( $product ): bool;
$product(WC_Product) (required)
WooCommerce product.

UcpProductMapper::has_catalog_variants() code WC 11.3.0

public function has_catalog_variants( \WC_Product $product ): bool {
	if ( ! $product instanceof \WC_Product_Variable ) {
		return true;
	}

	return ! empty( $product->get_visible_children() );
}