Last active
October 13, 2022 16:22
-
-
Save ben-heath/9f29c5a6c0b65d174dce14af1792bd40 to your computer and use it in GitHub Desktop.
Add content to WooCommerce Additional Information Tab on Single Products
This file contains hidden or 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 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 | |
} | |
?> |
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.
@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
Wow,
Gratful to you for this precious peice of code. Thanks for great work :)