Automattic\WooCommerce\Blocks\BlockTypes

ProductQuery::get_filter_by_attributes_query_vars()privateWC 1.0

Get all the query args related to the filter by attributes block.

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

Хуков нет.

Возвращает

Массив [color]. => Array ( [filter] => filter_color [query_type] => query_type_color

)
[size] => Array

(
	[filter] => filter_size
	[query_type] => query_type_size
)

)

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

// private - только в коде основоного (родительского) класса
$result = $this->get_filter_by_attributes_query_vars();

Код ProductQuery::get_filter_by_attributes_query_vars() WC 7.3.0

private function get_filter_by_attributes_query_vars() {
	if ( ! empty( $this->attributes_filter_query_args ) ) {
		return $this->attributes_filter_query_args;
	}

	$this->attributes_filter_query_args = array_reduce(
		wc_get_attribute_taxonomies(),
		function( $acc, $attribute ) {
			$acc[ $attribute->attribute_name ] = array(
				'filter'     => AttributeFilter::FILTER_QUERY_VAR_PREFIX . $attribute->attribute_name,
				'query_type' => AttributeFilter::QUERY_TYPE_QUERY_VAR_PREFIX . $attribute->attribute_name,
			);
			return $acc;
		},
		array()
	);

	return $this->attributes_filter_query_args;
}