Can you hide empty terms using get_term_children?

With the get_term_children() function there is nothing to pass which will hide empty terms. You could do that in your foreach as each term has a property which holds how many posts it is assigned:

foreach( $style_categories as $style ) {
    
    $child = get_term_by( 'id', $style, 'product_cat' );
    
    // Skip empty terms
    if( $child->count <= 0 ) {
        continue;
    }
}

The way it stands now you’re creating multiple queries – a better solution would be to use get_terms() instead.

get_terms( [ 'taxonomy' => 'product_cat', 'child_of' => 29] );

get_terms will hide the terms that have no post, you can change that with the hide_empty argument.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)