title: How to get Variation Product ID that is added to Cart
body: <p>I am having a trouble on getting the variation ID for the items that are added into cart. Currently my cart have variation product and I would like to get the variation ID. What I have tried is as below:</p>
  <pre><code>add_action( 'woocommerce_before_checkout_form',  &quot;test&quot; );
  
  function test(){
      $cart = WC()-&gt;cart;
      $test = WC()-&gt;cart-&gt;get_cart_contents_count();
      
      foreach ( WC()-&gt;cart-&gt;get_cart() as $cart_item_key =&gt; $cart_item ) {
  
         $product = $cart_item['data'];
         $product_id = $cart_item['product_id'];
         $quantity = $cart_item['quantity'];
         $price = WC()-&gt;cart-&gt;get_product_price( $product );
          
         $subtotal = WC()-&gt;cart-&gt;get_product_subtotal( $product, $cart_item['quantity'] );
         $link = $product-&gt;get_permalink( $cart_item );
          echo &quot;Product ID: &quot;. $product_id;
          echo &quot;&lt;br&gt;&quot;;
          echo &quot;Quantity: &quot;.$quantity;
          echo &quot;&lt;br&gt;&quot;;
          echo &quot;Price: &quot;.$price;
          echo &quot;&lt;br&gt;&quot;;
          echo &quot;&lt;br&gt;&quot;;    
      }
      
  }
  </code></pre>
  <p>The above code return me the parent ID instead of the variation ID.</p>
  <p><a href="https://i.stack.imgur.com/XVJNN.png" rel="nofollow noreferrer">Output</a></p>
  <p>Based on the Screenshot, the first product, product ID: 3117 which have a quantity of 4 should be a variation product which have an ID of 25663. How do I modify the code to get the variation ID instead of parent ID?</p>