title: Check if a product variation is in cart in Woocommerce
body: <p>I am trying display if a variation of a product is already in a cart or not (in single product page). A simple comparing of the product id with products in cart object is not working for variable product as the variation id is being loaded using ajax.  </p>
  
  <p>Here is my code that works in case the product type is other than variable.  </p>
  
  <pre><code>&lt;?php
  /*
   * Check if Product Already In Cart
  */
  function woo_in_cart( $product_id ) {
      global $woocommerce;
  
      if ( !isset($product_id) ) {
          return false;
      }
  
      foreach( $woocommerce-&gt;cart-&gt;get_cart() as $cart_item ) {
          if ( $cart_item['product_id'] === $product_id ){
              return true;
          } else {
              return false;
          }
      }
  }  
  </code></pre>
  
  <p>Is there any way to make it work without jQuery?</p>