Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save atxiii/c1b189e25207c1815072e6c433234447 to your computer and use it in GitHub Desktop.
Save atxiii/c1b189e25207c1815072e6c433234447 to your computer and use it in GitHub Desktop.
Add WooCommerce Brands logo with description to Additional Information product tab
<?php
// This code should be added to the functions.php file of the child theme
// Add WooCommerce Brands logo with description to Additional Information product tab
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product;
$tabs['additional_information']['callback'] = 'add_brand_to_info'; // this is the function name which is included below
return $tabs;
}
function add_brand_to_info(){
woocommerce_product_additional_information_tab(); // This function calls wc_get_template( 'single-product/tabs/additional-information.php' );
echo '<div class="brand-details">';
// add image with shortcode
echo do_shortcode('[product_brand width="64px" height="64px" class="alignright"]');
// add description
global $post;
$brands = wp_get_post_terms( $post->ID, 'product_brand', array("fields" => "all") );
foreach( $brands as $brand ) {
echo term_description( $brand->term_id, 'product_brand' );
}
echo '</div>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment