WC_Brands::update_product_query_tax_query()publicWC 1.0

Update the main product fetch query to filter by selected brands.

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

Хуков нет.

Возвращает

Массив.

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

$WC_Brands = new WC_Brands();
$WC_Brands->update_product_query_tax_query( $tax_query );
$tax_query(массив) (обязательный)
array of current taxonomy filters.

Код WC_Brands::update_product_query_tax_query() WC 9.4.2

public function update_product_query_tax_query( array $tax_query ) {
	if ( isset( $_GET['filter_product_brand'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		$filter_product_brand = wc_clean( wp_unslash( $_GET['filter_product_brand'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		$brands_filter        = array_filter( array_map( 'absint', explode( ',', $filter_product_brand ) ) );

		if ( $brands_filter ) {
			$tax_query[] = array(
				'taxonomy' => 'product_brand',
				'terms'    => $brands_filter,
				'operator' => 'IN',
			);
		}
	}

	return $tax_query;
}