title: WooCommerce get_sku(); on products variations in order
body: <p>I'm building a custom function for Woocommerce where I need to get product SKU and if 'variation' product get variation specific SKU.  </p>
  
  <p>What I currently have is the following:</p>
  
  <pre><code>// Query order data
  $order = new WC_Order($order_id);
  $items = $order-&gt;get_items();
  
  // Output the loop
  foreach ($order-&gt;get_items() as $item) {
      // Getting some information
      $product_name = $item['name'];
      $product_id = $item['product_id'];
      $product_qty = $item['qty'];
      $product_variation_id = $item['variation_id'];
      $product = new WC_Product($item['product_id']);
      // SKU
      $SKU = $product-&gt;get_sku();
  </code></pre>
  
  <p>It works good except when it comes to variations, I Have spent much time trying to figure this out and to find a good answer without any succes. </p>
  
  <p>I come to understand that I should use something like this:</p>
  
  <pre><code>$available_variations = $product-&gt;get_available_variations();
  </code></pre>
  
  <p>The crazy thing is that I did have this working but I didn't made a Git commit, thus I'm not able to revert the correct code. All the examples I found pretty much exist of a lot of code, but I'm sure this can be done using a much simpler and better performing method.</p>