title: woocommerce - How do I get the most top level category of the current product category
body: <p>I have a Woocommerce product and I need to display on that page the Most top level category of a category assigned to the product</p>
  
  <pre><code>- Main Product Category
  -- Sub Product Category
  --- Category Assigned to product
  </code></pre>
  
  <p>I need to get the ID or name of "Main Product Category" so that I can display it in the single product category. </p>
  
  <p>I already tried doing the following:</p>
  
  <pre><code>global $post;
  $terms = get_the_terms( $post-&gt;ID, 'product_cat' );
  
  foreach ($terms as $term) {
  $product_cat_id = $term-&gt;term_id;
  
  $thetop_parent = woocommerce_get_term_top_most_parent( $product_cat_id , 'product_cat' );
  
  echo $thetop_parent;
  }
  </code></pre>
  
  <p>But It didn't worked at all and it brakes the page from loading after woocomerce_get_term... I'm not sure what to do at this point It</p>
  
  <p>thanks for any help on this.</p>