Show attribute description when filtering by that attribute

You need to check when filter is enabled and take selected attribute taxonomy, ‘pa_brand’ in this case:

add_action( 'woocommerce_before_shop_loop', 'desc_before', 75 ); 

function desc_before() {
    if (is_filtered()) { 
        $brands = WC_Query::get_layered_nav_chosen_attributes() ['pa_brand'];
        if ( isset($brands) ) { 
            foreach ($brands['terms'] as $term ) {
                $term_obj  = get_term_by('slug', $term, 'pa_brand');

                echo '<div class="ka-attr-description">'.
                     '<h4>' . $term_obj ->name . '</h4>'.
                     $term_obj->description.
                     '</div>';
            } 
        }
    }
}

Leave a Comment