title: Hide a specific Woocommerce products from loop if they are in cart
body: <p>I'm trying to write a hook that hides a specific product from the shop page if it's in the cart, but I can't seem to figure out two things.</p>
  
  <pre><code>function find_product_in_cart() {
  
      $hide_if_in_cart = array(6121, 6107, 14202, 14203);
      $in_cart = false;
  
      foreach( WC()-&gt;cart-&gt;get_cart() as $cart_item ) {
  
          $product_in_cart = $cart_item['product_id'];
  
          foreach ( $hide_if_in_cart as $key =&gt; $value ) {
              if ( $product_in_cart === $value ) {
                  $in_cart = true;
              }
          }
  
          if ( $in_cart ) {
              echo 'Product in cart';
          } else {
              echo 'Not in cart!';
          }
  
      }
  }
  add_action('woocommerce_before_shop_loop_item', 'find_product_in_cart
  </code></pre>
  
  <ol>
  <li>The code prints out "Product in cart" everywhere, because one product with ID '14202' is in the cart. My logic is wrong somewhere...</li>
  <li>I don't know how to hide a single product, right now I print a line of text, but I want to be able to either display: none; it or maybe use a specific function that hides product in certain scenario's.</li>
  </ol>
  
  <p>This is the output at the moment:
  <a href="https://i.gyazo.com/d85bd93598ada7aa96bee9a1d7393c3c.png" rel="nofollow noreferrer">https://i.gyazo.com/d85bd93598ada7aa96bee9a1d7393c3c.png</a></p>