title: How to get Woocommerce Current Variation ID?
body: <p>I am trying to create some additional functionality on my Woocommerce backend where I add a custom field to the variations section of backend of Woocommerce.  However I cannot for the life of me figure out how to get the current variation id so I can get the post meta.</p>
  
  <p>here is what I have been working with:</p>
  
  <pre><code>&lt;?php
  
          // Get variations
          $args = array(
                       'post_type'     =&gt; 'product_variation',
                       'post_status'   =&gt; array( 'private', 'publish' ),
                       'numberposts'   =&gt; -1,
                       'orderby'       =&gt; 'menu_order',
                       'order'         =&gt; 'asc',
                       'post_parent'   =&gt; $post-&gt;ID
                   );
                   $variations = get_posts( $args ); 
  
          foreach ( $variations as $variation ) {
  
                       $variation_id           = absint( $variation-&gt;ID );$variable_id = $this['variation_id'];
                       $variation_post_status  = esc_attr( $variation-&gt;post_status );
                       $variation_data         = get_post_meta( $variation_id );
                       $variation_data['variation_post_id'] = $variation_id;
                      echo get_post_meta( $variation_data['variation_post_id'], '_my_custom_field', true) . ' - TEST';
  
                   }
  
       ?&gt;
  </code></pre>
  
  <p>When I check the backend it looks like it is pulling all the post meta into each variation like this:</p>
  
  <p><img src="https://i.stack.imgur.com/epum1.png" alt="enter image description here"></p>
  
  <p>However if I use the actual variation id like the below then it works for that variation:</p>
  
  <pre><code>echo get_post_meta( 134, '_my_custom_field', true) . ' - Test Variation #134';
  </code></pre>