title: Checking products in cart based on category name woocommerce?
body: <p>I'm trying to trigger an echo statement if a certain category of product is in my cart, here's my code:</p>
  
  <pre><code>&lt;?php
  //Check to see if user has product in cart
  global $woocommerce;
  
  //flag no book in cart
  $item_in_cart = false;
  
  foreach ( $woocommerce-&gt;cart-&gt;get_cart() as $cart_item_key =&gt; $values ) {
      $_product = $values['data'];
          $terms = get_the_terms( $_product-&gt;id, 'product_cat' );
  
              foreach ($terms as $term) {
                  $_categoryid = $term-&gt;term_id;
              }
  
      if ( $_categoryid == 'name_of_category' ) {
          //book is in cart!
          $item_in_cart = true;
  
      }
  }
  
  if ($item_in_cart === true) {echo 'YES';}
  else {echo 'Nope!';}
  
  ?&gt;
  </code></pre>
  
  <p>Any idea as to what i'm doing wrong? I do have 'name_of_category' products in my cart, i'd like a nice Yes echoed!</p>
  
  <p>Thanks!</p>