In WooCommerce, I would like to add custom global product tab just like additional info when a new product is created.
I am able to create new tab but cannot update anything on create new product page.
I can see it on display page but how to add info through product edit page. I know I can use custom fields but I am looking to have it on product page to allow shop manager or others to fill this additional shipping tab.
My Code is
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
function woo_new_product_tab( $tabs ) {
// Adds the new tab
$tabs['test_tab'] = array(
'title' => __( 'Shipping', 'woocommerce' ),
'priority' => 50,
'callback' => 'woo_new_product_tab_content'
);
return $tabs;
}
function woo_new_product_tab_content() {
// The new tab content
$prod_id = get_the_ID();
echo'<p>'.get_post_meta($prod_id,'Shipping',true).'</p>';
}
You can add a custom Metabox in Admin Product pages that will allow Shop Managers to add content for your custom product tab. You will get this:
Here is the code:
Then your own code will be:
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and works.