WooCommerce Brands: display brand description on product page
WooCommerce has a very good add-on called “WooCommerce Brands” to help you link products to brands. This plugin provides a huge list of shortcode and builtin functions to display pretty much everything everywhere. However, I’d like to share a little very useful snippet to automatically display the brands description on the product page itself, below the product description.
To do so, I simply created a little function that I hooked to the woocommerce_single_product_summary action. The code I propose is very simple and could be improved pretty easily, but I just want to provide the basics. Then it’s up to you to make something truly awesome with that snippet! And if you do, please write a comment to share your improvements!
Place the following snippet in functions.php in your theme folder (in wp-content/themes/your-theme-folder).
<?php
add_action( 'woocommerce_single_product_summary' , 'woocommerce_brand_summary', 25 );
/**
* woocommerce_brand_summary
*
* @access public
* @since 1.0
* @return void
*/
function woocommerce_brand_summary() {
global $post;
$brands = wp_get_post_terms( $post->ID, 'product_brand', array("fields" => "all") );
foreach( $brands as $brand ) {
echo __( 'Brand Description', '') . ': ' . term_description( $brand->term_id, 'product_brand' );
}
}