Hi:
As a request from a customer, we added a code to display the attributes, just under the categories name.
The function works, but we cannot format anything in the echo function. Since it works with other themes, does Legenda format this output before displaying it?
This is the code that we added to the functions.php. The class is formatted as bold. I’ve even tried to add a style=”font-weight:bold;” in the <span>.
Thanks
————– code at functions.php ————————-
<?php
define(‘ETHEME_DOMAIN’, ‘legenda’);
require_once( get_template_directory() . ‘/framework/init.php’ );
/**
* Show all product attributes on the product page
*/
function isa_woocommerce_all_pa(){
global $product;
$attributes = $product->get_attributes();
if ( ! $attributes ) {
return;
}
$out = ”;
foreach ( $attributes as $attribute ) {
// skip variations
if ( $attribute[‘is_variation’] ) {
continue;
}
if ( $attribute[‘is_taxonomy’] ) {
$terms = wp_get_post_terms( $product->id, $attribute[‘name’], ‘all’ );
// get the taxonomy
$tax = $terms[0]->taxonomy;
// get the tax object
$tax_object = get_taxonomy($tax);
// get tax label
if ( isset ($tax_object->labels->name) ) {
$tax_label = $tax_object->labels->name;
} elseif ( isset( $tax_object->label ) ) {
$tax_label = $tax_object->label;
}
foreach ( $terms as $term ) {
$out .= $tax_label . ‘: ‘;
$out .= $term->name . ‘<br />’;
}
} else {
$out .= ‘<span class=”attribute-label”>’ . $attribute[‘name’] . ‘: </span> ‘;
$out .= ‘<span class=”attribute-value”>’ . $attribute[‘value’] . ‘</span><br />’;
}
}
// echo ‘<br /> <br />’;
echo $out;
echo ‘<br /> <br/>’;
}
add_action(‘woocommerce_single_product_summary’, ‘isa_woocommerce_all_pa’, 3);