WordPress Check current category has child category

$current_cat_obj = get_queried_object(); $children_category = category_has_children($current_cat_obj->term_id,'product_cat'); function category_has_children( $term_id = 0, $taxonomy = 'category' ) { $children = get_categories( array( 'child_of' => $term_id, 'taxonomy' => $taxonomy ) ); return ( $children ); }