title: Get quantity of the active selected product variation in WooCommerce
body: <p>I am building a shop online (with Woocommerce) that will display single and variable products. When in the single products page, I need some output/text to depend upon the selected product in the single product page being in or out of stock. I am building this conditioning in PHP. </p>
  
  <p>For single products this is trivial:</p>
  
  <pre><code>$qty = $product-&gt;get_stock_quantity();
  if ( ( ... ) and ( $qty &gt; 0 ) ) {
      ...
  }
  </code></pre>
  
  <p>I am hooking in <code>'woocommerce_before_add_to_cart_button'</code>.</p>
  
  <p>However, for variable products I just don't know how to make it work. In this case, I need to get the selected/active variation quantity and this has to cope with the possibility of the client changing the variation in the page.</p>
  
  <p>This question has been raised before BUT mostly for all variations and not the current/active one.</p>
  
  <p>I would be grateful if someone could shed some light.</p>