I’m going to show you a simple PHP snippet to echo the variations’ name and stock quantity on the shop, categories and loop pages.
Of course, if “Manage stock” is not enabled at variation level, the quantity will be null, and therefore the returned string will just say “In stock” or “Out of stock”.
Enjoy!
PHP Snippet: Display Variations’ Name & Stock At WooCommerce Shop Page
Is there Relevant plugin?
If you want more customization of your variation product then you can do it easily using Variation Monster plugin. This plugin will give you more freedom to customize your Variable product.
Where to add custom code?
You should place custom PHP in functions.php and custom CSS in style.css of your child theme.
This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again.