title: Conditional function that check if products are already in cart in Woocommerce 3
body: <p>Hi solution provided here <a href="https://stackoverflow.com/questions/41262426/woocommerce-check-if-items-are-already-in-cart">WooCommerce - Check if item&#39;s are already in cart</a> working perfect. This is the function code:</p>
  
  <pre><code>function woo_in_cart($arr_product_id) {
      global $woocommerce;
      $cartarray=array();
  
      foreach($woocommerce-&gt;cart-&gt;get_cart() as $key =&gt; $val ) {
         $_product = $val['product_id'];
         array_push($cartarray,$_product);
      }
  
      if (!empty($cartarray)) {
         $result = array_intersect($cartarray,$arr_product_id);
      }
  
      if (!empty($result)) {
         return true;
      } else {
         return false;
      };
  
  }
  </code></pre>
  
  <p>Usage</p>
  
  <pre><code>  $my_products_ids_array = array(22,23,465);
  if (woo_in_cart($my_products_ids_array)) {
    echo 'ohh yeah there some of that products in!';
  }else {
    echo 'no matching products :(';
  }
  </code></pre>
  
  <p>But I need use as if(in_array) but no luck so far. What i doing wrong?</p>
  
  <pre><code>$my_products_ids_array = array("69286", "69287",);
  if (in_array("69286", $my_products_ids_array)) {
      echo '&lt;p&gt;' . the_field ( 'cart_field', 'option' ) . '&lt;/p&gt;';
  }
  if (in_array("69287", $my_products_ids_array)) {
      echo '&lt;p&gt;' . the_field ( 'cart_field-1', 'option' ) . '&lt;/p&gt;';
  }
  </code></pre>
  
  <p>Thank you</p>