How to Rename a Tab on the Product Page in WooCommerce

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.

Leave a Comment