title: get woocommerce categories with subcategory
body: <p>I want to get all woocommerce category's in front-end with subcategory like this result: </p>
  
  <pre><code>&lt;ul&gt;
      &lt;li&gt;&lt;a href=""&gt;Link&lt;/a&gt;
          &lt;ul&gt;
              &lt;li&gt;&lt;a href=""&gt;Submenu link&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Here is what i have (But it's Not what i want) :</p>
  
  <pre><code>&lt;?php
  
    $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'     =&gt; $taxonomy,
           'orderby'      =&gt; $orderby,
           'show_count'   =&gt; $show_count,
           'pad_counts'   =&gt; $pad_counts,
           'hierarchical' =&gt; $hierarchical,
           'title_li'     =&gt; $title,
           'hide_empty'   =&gt; $empty
    );
   $all_categories = get_categories( $args );
   foreach ($all_categories as $cat) {
      if($cat-&gt;category_parent == 0) {
          $category_id = $cat-&gt;term_id;       
          echo '&lt;li&gt;&lt;a href="'. get_term_link($cat-&gt;slug, 'product_cat') .'"&gt;'. $cat-&gt;name .'&lt;/a&gt;&lt;/li&gt;';
  
          $args2 = array(
                  'taxonomy'     =&gt; $taxonomy,
                  'child_of'     =&gt; 0,
                  'parent'       =&gt; $category_id,
                  'orderby'      =&gt; $orderby,
                  'show_count'   =&gt; $show_count,
                  'pad_counts'   =&gt; $pad_counts,
                  'hierarchical' =&gt; $hierarchical,
                  'title_li'     =&gt; $title,
                  'hide_empty'   =&gt; $empty
          );
          $sub_cats = get_categories( $args2 );
              if($sub_cats) {
                  foreach($sub_cats as $sub_category) {
                      echo  '&lt;li&gt;&lt;a href="'. get_term_link($sub_category-&gt;slug, 'product_cat') .'"&gt;'. $sub_category-&gt;name .'&lt;/a&gt;&lt;/li&gt;';
                  }
              }
          }       
  }
  ?&gt;  
  </code></pre>
  
  <p>this code show's category and subcategory but the subcategory is not where should be, the subcategory is like separate link like this:</p>
  
  <pre><code>&lt;ul&gt;
      &lt;li&gt;&lt;a href=""&gt;link&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=""&gt;Submenu link&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>