How to Rename a Tab on the Product Page in WooCommerce

Learning WooCommerce Development by Example
A Friendly and Accessible Guide to WooCommerce Development
Click here to get the book now for $29

On the WooCommerce single product page there are a number of tabs that are shown by default on each product page. They will typically look similar to the image below

What if we wanted to change the text one of the tabs? Well, we could do it using the snippet below

/*
* @snippet     Rename one of the tabs on the single product info page
* @author      Hard Working Nerd
* @testedon    WooCommerce 4.4.1
*/

add_filter( 'woocommerce_product_tabs', 'rename_additional_information_tab', 100, 1 );
function rename_additional_information_tab( $tabs ) {
    if (isset($tabs['additional_information'])) {
	    $tabs['additional_information']['title'] = __( 'Specs', 'woocommerce' );
    }
	return $tabs;
}

If you add the snippet above to your WooCoomerece enabled website then it will change the title of the “Additional Information” tab to read “Specs”

How does the Snippet work?

The snippet hooks into the woocommerce_product_tabs filter, it then finds the additional_information entry in the $tabs array and changes the title to something of our choosing.

One key thing to note from the code is the use of the isset function on line 3. This function is required because the “Additional information” tab is not shown on every product page, it is only shown on product pages where the product has attributes or has dimensions (such as weight and height). Because of this, the WooCommerce codebase only includes the additional_information  element in the tabs array when a suitable product is being displayed.

If we did not include the isset function then the snippet would always add an additional_information  element to the array even when it didn’t exist, this would lead to a tab being displayed on every product page with the title “Specs”, but on pages where no relevant product information was available, the tab contents would always be blank.

Did that Help?

Hopefully, this post has helped you to modify your WooCommerce store successfully, but if it hasn’t, or you have any additional questions. Then please don’t hesitate to let me know in the comments.

Hey there! Hope you enjoyed that article, thanks for sticking with it until the end 🙂

If you enjoy our WooCooomerce writing you might enjoy our book "Learning WooCommerce Development By Example", it's only $29 and contains a multitude of useful information for WooCommerce developers. Click here for more details.

You might also like to sign up for our newsletter, where you'll be kept to date with all our latest WooCommerce articles. Just complete the form below to get the latest Hard Working Nerd WooCommerce content delivered straight to your inbox.

Leave a Comment