The short answer is to get your taxonomy terms using:
wp_get_post_terms( $post->ID, 'yourTaxonomyName' );
This will return an array of WP Term Objects. Here’s how you would get the first term name:
$terms = wp_get_post_terms( $post->ID, 'yourTaxonomyName' );
$first_term_name = $terms[0]->name;
You can learn more about this method in the WordPress Codex:
https://codex.wordpress.org/Function_Reference/wp_get_post_terms
Hope this helps 🙂
Updated:
private function get_product_name( $product ) {
// Get all the country terms associated with $product.
$terms = wp_get_post_terms($product->ID, 'country');
// Set the empty $country string.
$country = '';
// Check if there are country terms available.
if($terms){
// If there are terms then use the first one to populate the $country variable.
$country = '</br><i>' . $terms[0]->name . '</i>';
}
// Add $country to the $name variable.
$name = wcpt_get_name( $product ) . $country . '</td>';
// This part could rewrite $name which would remove $country.
if ( array_intersect( [ 'all', 'name' ], $this->args->links ) ) {
$name = WCPT_Util::format_product_link( $product, $name );
}
return apply_filters( 'wc_product_table_data_name', $name, $product );
}