Automattic\WooCommerce\Internal\ProductAttributesLookup

LookupDataStore::get_attribute_taxonomies()privateWC 1.0

Return the list of taxonomies used for variations on a product together with the associated term ids, with the following format:

[ 'taxonomy_name' => [

'term_ids' => [id, id, ...],
'used_for_variations' => true|false

], ... ]

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

Хуков нет.

Возвращает

Массив. Information about the attribute taxonomies of the product.

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

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

Код LookupDataStore::get_attribute_taxonomies() WC 8.7.0

private function get_attribute_taxonomies( \WC_Product $product ) {
	$product_attributes = $product->get_attributes();
	$result             = array();
	foreach ( $product_attributes as $taxonomy_name => $attribute_data ) {
		if ( ! $attribute_data->get_id() ) {
			// Custom product attribute, not suitable for attribute-based filtering.
			continue;
		}

		$result[ $taxonomy_name ] = array(
			'term_ids'            => $attribute_data->get_options(),
			'used_for_variations' => $attribute_data->get_variation(),
		);
	}

	return $result;
}