Do you want to add a new tab on the product page of your WooCommerce store? Customers need to be informed about the products that you are selling to them. This is why WooCommerce includes a single product page to display all the relevant information about the products you sell.
From the back end, you can modularize the content and present lots of information about the product. The design is clean and does not overwhelm the user.
Add New Tab WooCommerce Product Page
You may want to add a custom tab on the WooCommerce product page to add more information about your products. Remember the more, the better.
However, by default, WooCommerce has three tabs only. They are:
- Additional information
- Reviews
- Description (displayed only if you have added description content for the product)
Here is how they are displayed in the front end:
These are the default tab content structure in WooCommerce.
In this tutorial, we will share with you how to add a custom tab using a PHP script. There are many plugins in the market today, which can help you achieve this. Some of them are premium and some free.
However, they may collide with your theme, or some will not work on your site. Let us look at how you can achieve this programmatically.
Steps to Add New Tab WooCommerce Product Page
Here are the steps that you need to follow:
- Log into your WordPress site and access the Dashboard as the admin user.
- From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file where we will add the function that will add a custom tab on the WooCommerce product page.
- Add the following code to the php file:
* Add a custom product data tab
*/
add_filter( ‘woocommerce_product_tabs’, ‘njengah_new_product_tab’ );
function njengah_new_product_tab( $tabs ) {
// Adds the new tab
$tabs[‘test_tab’] = array(
‘title’ => __( ‘New Product Tab’, ‘woocommerce’ ),
‘priority’ => 50,
‘callback’ => ‘njengah_new_product_tab_content’
);
return $tabs;
}
function njengah_new_product_tab_content() {
// The new tab content
echo ‘New Product Tab’;
echo ‘Here\’s your new product tab.’;
}[/php]
How the Code Works
The code helps you to add a custom tab programmatically. We’ve used the ‘woocommerce_product_tabs’
filter provided by WooCommerce to add a custom tab to a product page.
Once a custom tab has been added the content for the tab can be either added as static data or the content can be fetched from the custom fields added to the admin dashboard.
Conclusion
In this tutorial, you have learned how to add a custom tab on the product page. We recommend using a child theme to add the PHP snippets. It is important to add important information on the product page so that your customers can make an informed decision.
You should be very careful because any error will break down your site. This means that your customers will not be able to make purchases. If you encounter any problems, please contact a qualified WordPress developer.
Similar Articles
- 26 Best WooCommerce Plugins for Customer Feedback
- Elementor Review 2021 » Features, Pros, Cons, Pricing & Tutorial
- How to Hide Additional Information Tab In WooCommerce
- How to Hide Out of Stock Variations in WooCommerce
- How to Get Order ID on Checkout Page WooCommerce
- How to Hide SKU, Category, Tags Meta Product Page WooCommerce
- How to Hide Product Image on Cart Page WooCommerce
- 30+Best WordPress Membership Plugins Collection
- How to Adjust WooCommerce Storefront Height of Header
- How to Add Currency to WooCommerce [Custom Currency]
- How to Add WooCommerce Storefront Banner
- How to Create Checkbox Field in WooCommerce Checkout Page
- How to Remove Product Category Title WooCommerce
- How to Get Order Details After Checkout In WooCommerce
- How to Hide Prices From Google In WooCommerce
- How to Remove Product Image Placeholder In WooCommerce
- How to Add WooCommerce Invoice Checkout Page
- WooCommerce Redirect After Checkout : Redirect to Custom Thank You Page
- How to Edit Billing Details WooCommerce Checkout Page
- 100+ Tips, Tricks & Snippets Ultimate WooCommerce Hide Guide