Hide empty category on woocommerce

By your code i’m assuming your $child is the id of an term, the term object is being stored in the $term variable, so you can do this:

<?php if( $term->count > 0 ): ?>
  <li><a href="https://wordpress.stackexchange.com/questions/274628/<?php echo get_term_link( $child,"product_cat' )?>"><?php echo $term->name; ?></a></li>
<?php endif; ?>