I'm developing a theme for wordpress and woocommerce and need to show a variation's stock.
<p class="stock-m13"><?php echo $product->get_stock_quantity(); ?></p>
I read How to get the stock quantity of an article from woocommerce?, but this code only show me the global stock quantity, not each variation quantity.
Do I need another function to get variation quantity? Or it is possible that my code is not completed (I think it because I have used Twenty Fifteen theme and variation quantity is showed)?
I tried to get the max quantity with this:
<?php
foreach ($product->get_available_variations() as $key) {
echo $key['max_qty'] .'<br/>';
}
?>
And that works, but I don't know if this is useful when the stock goes down.