title: Using Conditional has_term() function for cart items in Woocommerce 3
body: <p>Please forgive me in advance if this is a stupid question.</p>
  
  <p>So, I'm currently doing a check on all the items in the WooCommerce Cart.</p>
  
  <p>If there's a product in the cart is in the category 'Practice' and there are no products in the cart with the category 'Qualifying', I want to show Message 1</p>
  
  <p>If both 'Practice' and 'Qualifying' categories are in the cart, I want to show message 2.</p>
  
  <p>Right now, here's my code:</p>
  
  <pre><code>&lt;?php 
     $category_checks = array();
  
     // check each cart item for our category
  
     foreach ( WC()-&gt;cart-&gt;get_cart() as $cart_item_key =&gt; $cart_item ) {
  
        $product = $cart_item['data'];
        $practice = false;
        $qualifying = false;
  
        if( has_term( 'practice', 'product_cat', $product-&gt;id ) &amp;&amp; ! has_term( 'qualifying', 'product_cat', $product-&gt;id ) ) : ?&gt;
  
           &lt;?php $practice = true; ?&gt;
  
           Upsell goes here (Message 1)
  
        &lt;?php elseif( has_term( 'practice', 'product_cat', $product-&gt;id ) &amp;&amp; has_term( 'qualifying', 'product_cat', $product-&gt;id ) ) : ?&gt;
  
           &lt;?php $qualifying = true; ?&gt;
  
           No need to upsell (Message 2)
  
         &lt;?php endif; ?&gt;
  
  &lt;?php      
  
  array_push( $category_checks, $practice, $qualifying );
   }
  
   if ( ! in_array( false, $category_checks, true ) ) {
  
   }
   ?&gt;
  </code></pre>
  
  <p>I have two products that have one category each, one has 'Practice' category and one has 'Qualifying' category.</p>
  
  <p>When I add these two products to the cart and try this code, I constantly get Message 1, even though I'm saying if it doesn't (!) have the term 'qualifying'.</p>
  
  <p>What am I doing wrong here?</p>