Automattic\WooCommerce\Internal\ProductAttributesLookup

LookupDataStore::get_variations_of │ private │ WC 1.0

Get the published variations of a given variable product.

Unpublished (disabled) variations get no lookup data: they can't be bought, so they mustn't make their parent match an attribute filter or count towards a term.

Метод класса: LookupDataStore{}

Хуков нет.

Возвращает

\WC_Product_Variation[].

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

// private - только в коде основоного (родительского) класса
$result = $this->get_variations_of( $product );
$product(WC_Product_Variable) (обязательный)
The product to get the variations for.

Код LookupDataStore::get_variations_of() WC 11.3.0

private function get_variations_of( \WC_Product_Variable $product ) {
	$variations = array_map(
		function ( $id ) {
			return WC()->call_function( 'wc_get_product', $id );
		},
		$product->get_children()
	);

	return array_filter( $variations, array( $this, 'is_published_variation' ) );
}