Skip to content

Instantly share code, notes, and snippets.

@jameskoster
Created March 11, 2013 11:24
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jameskoster/5133587 to your computer and use it in GitHub Desktop.
Save jameskoster/5133587 to your computer and use it in GitHub Desktop.
WooCommerce - Add new product tab
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>';
}
@ahmedofali
Copy link

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