Skip to content

Instantly share code, notes, and snippets.

@mehul0810
Last active April 5, 2016 06:58
Show Gist options
  • Save mehul0810/3605a2b4aaa396b7c81692c57666562e to your computer and use it in GitHub Desktop.
Save mehul0810/3605a2b4aaa396b7c81692c57666562e to your computer and use it in GitHub Desktop.
Woocommerce | Add Product Tab to Products Data Metabox under add new product
<?php
function add_my_custom_product_data_tab( $product_data_tabs ) {
$product_data_tabs['my-custom-tab'] = array(
'label' => __( 'My Custom Tab', 'my_text_domain' ),
'target' => 'my_custom_product_data',
);
return $product_data_tabs;
}
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' );
function add_my_custom_product_data_fields() {
global $woocommerce, $post;
?>
<!-- id below must match target registered in above add_my_custom_product_data_tab function -->
<div id="my_custom_product_data" class="panel woocommerce_options_panel">
<?php
woocommerce_wp_checkbox( array(
'id' => '_my_custom_field',
'wrapper_class' => 'show_if_simple',
'label' => __( 'My Custom Field Label', 'my_text_domain' ),
'description' => __( 'My Custom Field Description', 'my_text_domain' ),
'default' => '0',
'desc_tip' => false,
) );
?>
</div>
<?php
}
add_action( 'woocommerce_product_data_panels', 'add_my_custom_product_data_fields' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment