Created
March 11, 2013 11:24
-
-
Save jameskoster/5133587 to your computer and use it in GitHub Desktop.
WooCommerce - Add new product tab
This file contains 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
add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' ); | |
function woo_new_product_tab( $tabs ) { | |
// Adds the new tab | |
$tabs['test_tab'] = array( | |
'title' => __( 'New Product Tab', 'woocommerce' ), | |
'priority' => 50, | |
'callback' => 'woo_new_product_tab_content' | |
); | |
return $tabs; | |
} | |
function woo_new_product_tab_content() { | |
// The new tab content | |
echo '<h2>New Product Tab</h2>'; | |
echo '<p>Here\'s your new product tab.</p>'; | |
} |
Another Useful Example:
class Woo_Product_Tabs{
public static function init() {
add_action( 'woocommerce_product_write_panel_tabs',array( 'Woo_Product_Tabs', 'add_product_delivery_panel_tab' ) );
add_action( 'woocommerce_product_data_panels',array( 'Woo_Product_Tabs', 'add_product_delivery_panel_data' ) );
}
public static function add_product_delivery_panel_tab() {
?>
<li class="delivery_options delivery_tab">
<a href="#delivery_product_data"><?php echo esc_html__( 'Delivery', 'theme_name' ); ?></a>
</li>
<?php
}
public static function add_product_delivery_panel_data() {
global $post;
?>
<div id="delivery_product_data" class="panel woocommerce_options_panel">
<div class="options_group">
<?php
$info = get_post_meta( $post->ID, 'info', true );
wp_editor( htmlspecialchars_decode( $info ), 'info', array() );
?>
</div>
</div>
<?php
}
}
Woo_Product_Tabs::init();
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Example of How to add html content in the new tab add this in the callback function