How to display the Woocommerce Category custom field content in single product

In this Topic, I want to show you How to display the Woocommerce Category custom field content in the single product page. After a lot of struggle, Finally, I have done my task with this code. Please see below.


if(is_product()){
global $product; $product_id = $product->get_id();

global $wp_query;
$terms_post = get_the_terms( $post->cat_ID , 'product_cat' );
$term = get_queried_object($terms_post);
foreach ($terms_post as $term_cat) {
$term_cat_slug = $term_cat->slug;
$product_id = 'product_cat_'.$term_cat->term_id;
$category_thumbnail = get_woocommerce_term_meta($term_cat->term_id, 'thumbnail_id', true);

$custom_field = get_field('YOUR_CUSTOM_FIELD_NAME', $term_cat);
//echo $custom_field;
}
//echo $post_id;
//echo $category_thumbnail;
//echo $term_cat_slug;
}
}

You just need to place this code in woocommerce.php or any other place where you want to get product related category detail. Thank you
Mar 9, 2018
Wordpress Bugs

Experts Replied:

Topic mark as closed!