Get for a specific attribute of a variation the corresponding data value
You need to use with the class WC_Product_Variation the method get_variation_attributes() that will returns an array of the attributes and their values for this variation.
So for attribute pa_shirt
your code to display the value for a specific variation is going to be:
$variations = $product->get_available_variations();// Here we use our method to get the array of attribute values for the variation$variation_attribute = $variation->get_variation_attributes();// Here is the value for this variation and "pa_shirt" attribute$variation_attrib_shirt_value = $variation_attribute['attribute_pa_shirt'];
As you can notice the attributes keys slugs in the array have all
'attribute_'
in the beginning.