Add Extra Tabs on WooCommerce Products

WooCommerce allows you to add extra tabs on a product page alongside description, reviews and additional information with the filter, woocommerce_product_tabs.

Let’s say you wanted 2 extra tabs – ‘Ingredients’ and ‘How To Use’ as the heading, you can use the filter woocommerce_product_tabs like so…

add_filter( 'woocommerce_product_tabs', 'woo_new_product_tab' );
/**
 * Add 2 custom product data tabs
 */
function woo_new_product_tab( $tabs ) {
	
	// Adds the new tab
	
	$tabs['ingredient_tab'] = array(
		'title' 	=> __( 'Ingredients', 'woocommerce' ),
		'priority' 	=> 15,
		'callback' 	=> 'ska_ingredients_callback'
        );
        
        $tabs['work_tab'] = array(
		'title' 	=> __( 'How To Use', 'woocommerce' ),
		'priority' 	=> 15,
		'callback' 	=> 'ska_works_callback'
	);

	return $tabs;

}

The array values are title for the Tab Title, the priority for how early it appears in the tab tow, lower numbers appear earlier and the callback which is the function called to output the tab’s content.

For the content of the tab you may wish to use a custom field as a text area with ACF – then echo the field name in the function callback…

function ska_ingredients_callback() {
        echo the_field('ska_ingredients');
}

function ska_works_callback() {
        echo the_field('ska_works');

}

This is how it will look

Woocommerce Tabs Extra Product

Here is how you can remove or re-order the tabs.

1 Comment

  1. […] Add Extra Tabs on WooCommerce Products […]

Leave a Comment