-
-
Save ben-heath/9f29c5a6c0b65d174dce14af1792bd40 to your computer and use it in GitHub Desktop.
<?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 | |
} | |
?> |
Wow,
Gratful to you for this precious peice of code. Thanks for great work :)
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! 👍
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.
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! :) 👍
@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
Works great, thanks!