I am using a lot of product attributes on my products in Woocommerce and I am looping through all variations in a table that can be displayed with a shortcode on a product page.
For this table I need all the product attributes in the table head (this is before looping through the variations) and I get the attributes using:
$attributes = $product->get_variation_attributes();
foreach ($attributes as $key => $value) {
echo '<td>'.&key.'</td>';
}
This isn't very elegant, is it?
So this works, too:
$attributes = $product->get_attributes();
foreach ($attributes as $attribute) {
echo '<td>'$attribute['name']'</td>';
}
In both cases I get the slug of the product attribute. I need to get the label name instead, since there is a Polylang translation for each name (terms also).
How can I get the product attribute label name instead of the taxonomy slug?