Last active
May 14, 2020 15:25
-
-
Save atxiii/c1b189e25207c1815072e6c433234447 to your computer and use it in GitHub Desktop.
Add WooCommerce Brands logo with description to Additional Information product tab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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