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
}
?>
@angeljs6
Copy link

Works great, thanks!

@meostar
Copy link

meostar commented Feb 17, 2020

Wow,
Gratful to you for this precious peice of code. Thanks for great work :)

@AndiZu2
Copy link

AndiZu2 commented Nov 16, 2020

Great stuff! How would I go about adding ACF custom field data to the 'Weight & Dimensions' table in the 'Additional Information' tab?

IE: I Wish to add two more rows namely: Fortruck Req? & Lead time (Both ACF Custom fields)

Thanks in advance! 👍

@ben-heath
Copy link
Author

@AndiZu2

I hadn't figured out how to edit the content within the table itself. This snippet was just to show how to content before and after the table. I'm sure there is a way, but I haven't needed to investigate it yet, so I'm not sure.

@AndiZu2
Copy link

AndiZu2 commented Nov 16, 2020

Hi Ben, thanks for the quick response! Yeah... Totally the same, It's not something I've ever had to address fella! Think I'll just use the old workaround! I'll just create new AFC fields for existing 'Additional Info' content. (Weight & Dimension) Sort & reload the Excel Worksheet. Then lose the standard WooCommerce Tabs, create a new Tab, and load the ACF into custom Elementor Templates. Bit of a fuck-about but at least I can get it to look how I want it to!

Thanks for your time tho! :) 👍

@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