In e-commerce, the product page is one of the most important pages of an online store. It is the page where customers get to see the details of a product they are interested in and make the decision to purchase it. A well-designed product page can greatly improve the customer experience and increase sales. However, in some cases, certain tabs on the product page may not be relevant or useful, and it may be beneficial to remove them. In this article, we will be discussing how to remove specific tabs from the product page in a WooCommerce store using a simple code snippet.

To use below code snippet, you will need to have a WordPress website with the WooCommerce plugin installed and activated. Once you have that set up, you can use the following steps to remove specific tabs from the product page:

  1. Open your website’s theme’s functions.php file. This file is located in the root folder of your active theme.

  2. Add the code snippet provided below to the functions.php file. Make sure to add it at the bottom of the file, but before the closing PHP tag (?>).

  3. Save the changes to the functions.php file.

  4. Visit your website’s product page to see the changes. The tabs that were specified in the code snippet (description, reviews and additional_information) will no longer be visible on the product page.

It’s worth noting that, you can change the tabs that need to be removed, by editing the unset function parameter, the specific tab’s name, inside the function.

Also, it’s recommended to backup your website’s files before making any changes to the code, in case of any errors you can restore your website to its previous state.

By following these steps, you should be able to remove specific tabs from the product page in your WooCommerce store using the code snippet provided.

Here’s a code snippet:

add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
 
function woo_remove_product_tabs( $tabs ) {
 
unset( $tabs['description'] );          // Remove the description tab
unset( $tabs['reviews'] );             // Remove the reviews tab
unset( $tabs['additional_information'] );      // Remove the additional information tab
 
return $tabs;
 
}

This code uses the WordPress and WooCommerce plugin functions to remove specific tabs from the product page of an online store.

  • The first line uses the add_filter() function, which is used to add a filter to a specific hook in WordPress. In this case, the filter is being added to the ‘woocommerce_product_tabs’ hook, which is used to display the tabs on a product page in WooCommerce. The second parameter of this function is the name of the function that will be used to perform the filtering (in this case, ‘woo_remove_product_tabs’). The third parameter, 98, is the priority of the filter (the order in which the filter should be executed in relation to other filters).

  • The next line defines the function ‘woo_remove_product_tabs’. The function takes one parameter, $tabs, which is an array of all the tabs that are currently being displayed on the product page.

  • The next three lines uses the unset() function to remove specific tabs from the $tabs array. The unset() function is used to remove a specific element from an array. In this case, the tabs for ‘description’, ‘reviews’ and ‘additional_information’ are being removed from the array.

  • The last line of the function returns the modified $tabs array, with the removed tabs.

Conclusion:

In conclusion, this code snippet uses the add_filter() and unset() functions to remove specific tabs from the product page in a WooCommerce store. The function is added to the ‘woocommerce_product_tabs’ hook and the specific tabs are removed from the array of tabs by using the unset() function. It’s a simple and easy way to improve the customer experience and increase sales by removing unnecessary tabs from the product page.