<?php
/** index only first level children terms, no grandchildren or deeper **/
add_filter( 'facetwp_index_row', function( $params ) {
if ( 'product_categories' == $params['facet_name'] ) { //change 'product_categories' to name of your facet
$parents = get_ancestors( $params['term_id'], 'product_cat', 'taxonomy' ); // change 'product_cat' to name of your taxonomy
if ( count( $parents ) !== 1 ) { // adjust comparison as needed for different child levels
return false;
}
}
return $params;
});