$terms = get_the_terms( $_product->id , 'product_cat');
if($terms) {
foreach( $terms as $term ) {
$term = get_term_by("id", $term->parent, "product_cat");
if ($term->parent > 0) {
$term = get_term_by("id", $term->parent, "product_cat");
}
$cat_obj = get_term($term->term_id, 'product_cat');
$cat_name = $cat_obj->name;
}
}
echo '<br />('. $cat_name . ')';
source
share