title: Get the product variations attributes values term ID and name
body: <p>In WooCommerce, I'm using <code>$product-&gt;get_variation_attributes()</code> to get the variations attributes for a product. This function returns an array with the names without the ID's.</p>
  
  <p>Like this:</p>
  
  <pre><code>                   [pa_color-shirt] =&gt; Array
                          (
                              [0] =&gt; red
                              [7] =&gt; grey
                              [14] =&gt; yellow
                          )
  
                      [pa_color-sweater] =&gt; Array
                          (
                              [0] =&gt; red
                              [1] =&gt; green
                              [2] =&gt; blue
                              [3] =&gt; grey
                              [4] =&gt; yellow
                              [5] =&gt; pink
                              [6] =&gt; dark-blue
                          )
  </code></pre>
  
  <p>For the AJAX shop I'm creating I also need the ID's from the variations.
  So I can append the Id's and the names to the select boxes (Like woocommerce does).<br>
  I searched around for days but couldn't find a solution.</p>
  
  <p>I created this code:</p>
  
  <pre><code>if($product-&gt;has_child()) {
                  $attributes = $product-&gt;get_attributes();
                  $variations = $product-&gt;get_available_variations();
                  $variationsArray = array();
                  foreach ($attributes as $attr =&gt; $attr_deets) {
                      $variationArray = array();
                      $attribute_label = wc_attribute_label($attr);
                      $variationArray["attribute_label"] = $attribute_label;
                      if (isset($attributes[$attr]) || isset($attributes['pa_' . $attr])) {
                          $attribute = isset($attributes[$attr]) ? $attributes[$attr] : $attributes['pa_' . $attr];
                          if ($attribute['is_taxonomy'] &amp;&amp; $attribute['is_visible']) {
                              $variationArray["attribute_name"] = $attribute['name'];
                              $variationIds = array();
                              $variationNames = array();
                              $variationPrices = array();
                              foreach ($variations as $variation) {
                                  if (!empty($variation['attributes']['attribute_' . $attribute['name']])) {
                                      array_push($variationIds, $variation['variation_id']);
                                      $taxonomy = $attribute['name'];
                                      $meta = get_post_meta($variation['variation_id'], 'attribute_'.$taxonomy, true);
                                      $term = get_term_by('slug', $meta, $taxonomy);
                                      $variation_name = $term-&gt;name;
                                      array_push($variationNames, $variation_name);
                                      array_push($variationPrices, $variation['display_regular_price']);
                                  }
                              }
                              $variationArray["variation_prices"] = $variationPrices;
                              $variationArray["variations"] = array_combine($variationIds, $variationNames);
                          }
                      }
                      array_push($variationsArray, $variationArray);
                  }
              }
  
              $product_variations = $variationsArray;
  </code></pre>
  
  <p>This code returns <a href="https://hastebin.com/ecebewumoz.php" rel="noreferrer">https://hastebin.com/ecebewumoz.php</a></p>
  
  <p>The code works but returns duplicate names and id's.</p>
  
  <p>My questions is does anyone know how I could accomplish the same as <code>get_variation_attributes()</code> but with the ID's?</p>
  
  <p>Thanks.</p>