Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions

Utils::is_not_purchasable_productpublic staticWC 1.0

Check if a product is not purchasable or not in stock.

Method of the class: Utils{}

No Hooks.

Returns

true|false. True if the product is not purchasable or not in stock.

Usage

$result = Utils::is_not_purchasable_product( $product );
$product(WC_Product) (required)
The product to check.

Utils::is_not_purchasable_product() code WC 10.3.6

public static function is_not_purchasable_product( $product ) {
	if ( $product->is_type( ProductType::SIMPLE ) ) {
		return ! $product->is_in_stock() || ! $product->is_purchasable();
	} elseif ( $product->is_type( ProductType::VARIABLE ) ) {
		return ! $product->is_in_stock() || ! $product->has_purchasable_variations();
	}

	return false;
}