Answer the question
In order to leave comments, you need to log in
How to display LABEL attribute in Woocommerce?
There is a solution for displaying product attribute values:
$attributes = $product->get_attributes();
$content = '<ul class="custom-attributes">';
foreach ( $attributes as $attribute ) {
if ($attribute['is_taxonomy']) {
$values = wc_get_product_terms($product->id, $attribute['name'], array('fields' => 'names'));
$content .= '<li><span class="attribute-label-text">___label___</span> : ';
$content .= apply_filters('woocommerce_attribute', implode(', ', $values), $attribute, $values);
$content .= '</li>';
}
}
$content .= '</ul>';
echo $content;
Answer the question
In order to leave comments, you need to log in
$attributes = $product->get_attributes();
$content = '<ul class="custom-attributes">';
foreach ( $attributes as $attribute ) {
if ($attribute['is_taxonomy']) {
$values = wc_get_product_terms($product->id, $attribute['name'], array('fields' => 'names'));
$content .= '<li><span class="attribute-label-text">'.wc_attribute_label( $attribute['name'] ).'</span> : ';
$content .= apply_filters('woocommerce_attribute', implode(', ', $values), $attribute, $values);
$content .= '</li>';
}
}
$content .= '</ul>';
echo $content;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question