Get the product attribute label name in Woocommerce 3 Get the product attribute label name in Woocommerce 3 wordpress wordpress

Get the product attribute label name in Woocommerce 3


You will use wc_attribute_label() dedicated Woocommerce function:

foreach ($product->get_variation_attributes() as $taxonomy => $term_names ) {    // Get the attribute label    $attribute_label_name = wc_attribute_label($taxonomy);    // Display attribute labe name    echo '<td>'.$attribute_label_name.'</td>';}

OR:

foreach ($product->get_attributes() as $taxonomy => $attribute_obj ) {    // Get the attribute label    $attribute_label_name = wc_attribute_label($taxonomy);    // Display attribute labe name    echo '<td>'.$attribute_label_name.'</td>';}