I am running into issues attempting to get the child brand terms for our product page. Product brands are setup like this below.
BRAND
MODEL
MODEL
MODEL
BRAND
MODEL
MODEL
ETC..
I am trying to display the child model that is assigned to the product, but cant seem to get anything to work. Here is my current code that display’s the BRAND. Any suggestions?
add_shortcode( 'show_keyfeatures_model', 'keyfeatures_model_shortcode' );
function keyfeatures_model_shortcode() {
global $product;
$terms = get_the_terms( get_the_ID(), 'product_brand' );
foreach ( $terms as $term ){
if ( 0 == $term->parent ) {
$brand_name= $term->slug;
}
}
$output_html = '';
if ( ! empty($brand_name)) {
$output_html .= '<table class="">';
if ( ! empty($brand_name) ) {
$output_html .= '<tr class="">
<td class=""><center><b>' . $brand_name . '</b></center></td>
</tr>';
}
$output_html .= '</table>';
}
return $output_html;
}