title: Get the id of a WooCommerce product category by its name or slug
body: <p>I have a wp template that I would like to assign to some pages. The template would ie. display all WooCommerce products that have the same master category name as the pages name itself. </p>
  
  <p>By far I have tried using this code, but with no good output:</p>
  
  <pre><code>$idObj = get_category_by_slug($pagename);
  $id = $idObj-&gt;term_id;
  echo ": ". $id;
  </code></pre>
  
  <p>Unfortunately, the echo does not display anything.<br>
  Echoing <code>$pagename</code> works, and returns me the slug of the page.</p>
  
  <p>Any good way I could make this work?</p>