title: How to get the active price of the selected variable product
body: <p>I am trying to access the product price of the selected product so I can use it in my PHP code to do some calculations. I have found a code that is working only partially. The code only displays the price of the first variable product. When I change the value from 0 to 1 in his code line it will display the price of the second variant. $availablevariations[0]['variation_id'].
  I am trying to get the current price of the product based on whatever option is selected from the drop down list. 
  Here is the code that I am using which is not working the way I would would like it to</p>
  
  <pre><code>    // Get current product variation price
      global $product;
  
      //get the sale price of the product whether it be simple, grouped or variable
      echo $saleprice = getpostmeta( gettheID(), '_price', true);
  
      //get the regular price of the product, but of a simple product
      $regular_price = get_post_meta( get_the_ID(), '_regular_price', true);
  
      //oh, the product is variable to $sale_price is empty? Lets get a variation price
  
      if ($regular_price == ""){
      #Step 1: Get product varations
      $available_variations = $product-&gt;get_available_variations();
  
      #Step 2: Get product variation id
      $variation_id=$available_variations[0]['variation_id']; // Getting the variable id of just the 1st product. You can loop $available_variations to get info about each variation.
  
      #Step 3: Create the variable product object
      $variable_product1= new WC_Product_Variation( $variation_id );
  
      #Step 4: You have the data. Have fun :)
      $regular_price = $variable_product1 -&gt;regular_price;
  </code></pre>
  
  <p>}</p>
  
  <pre><code>        echo "&lt;br&gt; $regular_price ---This is the price I am trying to fix "
  </code></pre>
  
  <p>I need this code to make some operation with the current variable product price, so if you want to see, the link is <a href="http://www.emotionadv.it/shop/volantini/volantino/" rel="nofollow">http://www.emotionadv.it/shop/volantini/volantino/</a> , when i change an attribute the price changes.
  I want to get that price to use in table under.</p>