Actually I found out later that the information I wanted was the variation name. After some research I come up with this code. It solves my problem but I don’t know if is the best solution.
<?php
if ( $product->is_type( 'variable' ) ) {
$attributes = $product->get_attributes();
$attribute_name = '';
foreach ( $attributes as $attribute ) {
$attribute_name = $attribute['name'];
}
$terms = wc_get_product_terms( $product->id, $attribute_name, array( 'fields' => 'all' ) );
for ( $i=0; $i < count($terms); $i++ ) {
if ( $i == count($terms)-1 ) {
echo $terms[$i]->name ;
}
else {
echo $terms[$i]->name . ' | ';
}
}
}
?>
How could I improve it? The major problem is in the loop for find the attribute name. In my case I just have one atribute, so thats ok, but in other situations, with more attributes that may cause a problem.