如何在WooCommerce - Wordpress上添加类别和子类别页面的类别

I'm having trouble with adding list (ul li) of categories on categories and subcategories pages. I've found some similar questions but found only half working solution. Here's what I managed to do: I found this peace of code

    function blue_categories()
{
  $taxonomy     = 'product_cat';
  $orderby      = 'name';  
  $show_count   = 0;      // 1 for yes, 0 for no
  $pad_counts   = 0;      // 1 for yes, 0 for no
  $hierarchical = 1;      // 1 for yes, 0 for no  
  $title        = '';  
  $empty        = 0;

  $args = array(
         'taxonomy'     => $taxonomy,
         'orderby'      => $orderby,
         'show_count'   => $show_count,
         'pad_counts'   => $pad_counts,
         'hierarchical' => $hierarchical,
         'title_li'     => $title,
         'hide_empty'   => $empty
  );
 $all_categories = get_categories( $args );
 foreach ($all_categories as $cat) {
    if($cat->category_parent == 0) {
        $category_id = $cat->term_id;       
        echo '<br /><a href="'. get_term_link($cat->slug, 'product_cat') .'">'. $cat->name .'</a>';

        $args2 = array(
                'taxonomy'     => $taxonomy,
                'child_of'     => 0,
                'parent'       => $category_id,
                'orderby'      => $orderby,
                'show_count'   => $show_count,
                'pad_counts'   => $pad_counts,
                'hierarchical' => $hierarchical,
                'title_li'     => $title,
                'hide_empty'   => $empty
        );
        $sub_cats = get_categories( $args2 );
        if($sub_cats) {
            foreach($sub_cats as $sub_category) {
                echo  $sub_category->name ;
            }   
        }
    }       
}
}

This does return list of categories and subcategories, but I cant find any documentation either on wordpress, avada (which is theme) or woocommerce, for where I have to call this function. I've added this function to functions.php, now I don't know where to call it. Where are "shop", "categories-page" or "subcategories-page" created ?

So my general question is, how can I display list of categories and subcategories on category & subcategory page IN SIDEBAR ? And I'm 1000% sure it cannot be done from backoffice settings, except editing functions.php and template files.