WC_Product_Variable::variation_is_available()privateWC 1.0

Check if a given variation is currently available.

{} Это метод класса: WC_Product_Variable{}

Хуки из метода

Возвращает

true|false. True if the variation is available, false otherwise.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->variation_is_available( $variation );
$variation(WC_Product_Variation) (обязательный)
Variation to check.

Код WC_Product_Variable::variation_is_available() WC 6.4.1

private function variation_is_available( WC_Product_Variation $variation ) {
	// Hide out of stock variations if 'Hide out of stock items from the catalog' is checked.
	if ( ! $variation || ! $variation->exists() || ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) && ! $variation->is_in_stock() ) ) {
		return false;
	}

	// Filter 'woocommerce_hide_invisible_variations' to optionally hide invisible variations (disabled variations and variations with empty price).
	if ( apply_filters( 'woocommerce_hide_invisible_variations', true, $this->get_id(), $variation ) && ! $variation->variation_is_visible() ) {
		return false;
	}

	return true;
}