WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Самая быстрая Тема-конструктор для WordPress
функция не описана

WC_Query::get_tax_query() public WC 1.0

Appends tax queries to an array.

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

Хуки из метода
Возвращает

Массив.

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

$WC_Query = new WC_Query();
$WC_Query->get_tax_query( $tax_query, $main_query );
$tax_query(массив)
Tax query.
По умолчанию: array()
$main_query(true/false)
If is main query.
По умолчанию: false

Код WC_Query::get_tax_query() WC 4.6.1

<?php
public function get_tax_query( $tax_query = array(), $main_query = false ) {
	if ( ! is_array( $tax_query ) ) {
		$tax_query = array(
			'relation' => 'AND',
		);
	}

	// Layered nav filters on terms.
	if ( $main_query ) {
		foreach ( $this->get_layered_nav_chosen_attributes() as $taxonomy => $data ) {
			$tax_query[] = array(
				'taxonomy'         => $taxonomy,
				'field'            => 'slug',
				'terms'            => $data['terms'],
				'operator'         => 'and' === $data['query_type'] ? 'AND' : 'IN',
				'include_children' => false,
			);
		}
	}

	$product_visibility_terms  = wc_get_product_visibility_term_ids();
	$product_visibility_not_in = array( is_search() && $main_query ? $product_visibility_terms['exclude-from-search'] : $product_visibility_terms['exclude-from-catalog'] );

	// Hide out of stock products.
	if ( 'yes' === get_option( 'woocommerce_hide_out_of_stock_items' ) ) {
		$product_visibility_not_in[] = $product_visibility_terms['outofstock'];
	}

	// phpcs:disable WordPress.Security.NonceVerification.Recommended
	// Filter by rating.
	if ( isset( $_GET['rating_filter'] ) ) {
		// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
		$rating_filter = array_filter( array_map( 'absint', explode( ',', wp_unslash( $_GET['rating_filter'] ) ) ) );
		$rating_terms  = array();
		for ( $i = 1; $i <= 5; $i ++ ) {
			if ( in_array( $i, $rating_filter, true ) && isset( $product_visibility_terms[ 'rated-' . $i ] ) ) {
				$rating_terms[] = $product_visibility_terms[ 'rated-' . $i ];
			}
		}
		if ( ! empty( $rating_terms ) ) {
			$tax_query[] = array(
				'taxonomy'      => 'product_visibility',
				'field'         => 'term_taxonomy_id',
				'terms'         => $rating_terms,
				'operator'      => 'IN',
				'rating_filter' => true,
			);
		}
	}
	// phpcs:enable WordPress.Security.NonceVerification.Recommended

	if ( ! empty( $product_visibility_not_in ) ) {
		$tax_query[] = array(
			'taxonomy' => 'product_visibility',
			'field'    => 'term_taxonomy_id',
			'terms'    => $product_visibility_not_in,
			'operator' => 'NOT IN',
		);
	}

	return array_filter( apply_filters( 'woocommerce_product_query_tax_query', $tax_query, $this ) );
}