woocommerce_get_filtered_term_product_counts_query filter-hookWC 2.6.1

Customizes the SQL query that populates product counts in layered navigation.

Usage

add_filter( 'woocommerce_get_filtered_term_product_counts_query', 'wp_kama_woocommerce_get_filtered_term_product_counts_query_filter' );

/**
 * Function for `woocommerce_get_filtered_term_product_counts_query` filter-hook.
 * 
 * @param array $query Query fragments (the available fragments are: select, from, join, where, group_by).
 *
 * @return array
 */
function wp_kama_woocommerce_get_filtered_term_product_counts_query_filter( $query ){

	// filter...
	return $query;
}
$query(array)
Query fragments (the available fragments are: select, from, join, where, group_by).

Changelog

Since 2.6.1 Introduced.
Since 10.9.0 the query was optimized to remove the join on term_relationships in favor of a nested select from term_relationships.

Where the hook is called

Filterer::get_filtered_term_product_counts()
woocommerce_get_filtered_term_product_counts_query
WC_Widget_Brand_Nav::get_filtered_term_product_counts()
woocommerce_get_filtered_term_product_counts_query
woocommerce/src/Internal/ProductAttributesLookup/Filterer.php 196
$query     = apply_filters( 'woocommerce_get_filtered_term_product_counts_query', $query );
woocommerce/includes/widgets/class-wc-widget-brand-nav.php 527
$query             = apply_filters( 'woocommerce_get_filtered_term_product_counts_query', $query ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment

Where the hook is used in WooCommerce

Usage not found.