Simple Product Attribute Description
-
I have a few custom attributes like “age” and “level” on for my simple products. These display just fine with the following code. However, I would like to include the description as well. For instance, if the Level is “Starter” then the it might show as LEVEL: Starter (description here). Any help? Thank you.
<?php foreach ( $attributes as $attribute ) : ?>
<div class=”ts-attribute”>
<?php echo wc_attribute_label( $attribute->get_name() ); ?>:
<?php
$values = array();if ( $attribute->is_taxonomy() ) {
$attribute_taxonomy = $attribute->get_taxonomy_object();
$attribute_values = wc_get_product_terms( $product->get_id(), $attribute->get_name(), array( ‘fields’ => ‘all’ ) );foreach ( $attribute_values as $attribute_value ) {
$value_name = esc_html( $attribute_value->name );if ( $attribute_taxonomy->attribute_public ) {
$values[] = ‘term_id, $attribute->get_name() ) ) . ‘” rel=”tag”>’ . $value_name . ‘‘;
} else {
$values[] = $value_name;
}
}
} else {
$values = $attribute->get_options();foreach ( $values as &$value ) {
$value = make_clickable( esc_html( $value ) );
}
}echo apply_filters( ‘woocommerce_attribute’, wptexturize( implode( ‘, ‘, $values ) ), $attribute, $values );
?>
</div><?php endforeach; ?>
The topic ‘Simple Product Attribute Description’ is closed to new replies.