Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ben-heath/9f29c5a6c0b65d174dce14af1792bd40 to your computer and use it in GitHub Desktop.
Save ben-heath/9f29c5a6c0b65d174dce14af1792bd40 to your computer and use it in GitHub Desktop.
Add content to WooCommerce Additional Information Tab on Single Products
<?php
// This code should be added to the functions.php file of the child theme
// Add custom info 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'] = 'custom_function_name'; // this is the function name which is included below
return $tabs;
}
function custom_function_name(){
echo 'New Content Here'; //add anything you want to show before the default tab content
woocommerce_product_additional_information_tab(); // This function calls wc_get_template( 'single-product/tabs/additional-information.php' );
echo 'New Content Here'; //add anything you want to show after the default tab content
}
?>
@jorgept
Copy link

jorgept commented Oct 13, 2022

@ben-heath , hi

I have these code


add_filter(` 'woocommerce_display_product_attributes', 'custom_product_additional_information', 10, 2 );
function custom_product_additional_information( $product_attributes, $product ) {
//row1
$product_attributes[ 'attribute_' . 'custom-two' ] = array(
'label' => __('ISBN'),
'value' => $product->get_meta('_isbn'),
);
return $product_attributes;
}


Is work for me,
but can't achieve hide, if value is empty.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment