In an e-commerce store powered by WooCommerce, the product page tabs play a crucial role in providing information to potential customers. By default, the “Description” tab is usually set as the active tab when a user lands on a product page.
However, in some cases, you might want to highlight the “Review” tab as the default active tab to encourage customers to read and leave reviews.
In this tutorial, we’ll show you how to achieve this by adding a simple code snippet to your Astra Child Theme’s functions.php file.
How to Set the “Review” Tab as the Default Active Tab in WooCommerce
Before we get started, make sure you have access to your WordPress admin dashboard. Then, follow these steps:
- Log in to your WordPress admin panel.
- Navigate to “Appearance” and click on “Theme Editor.”
- On the right side, you’ll see a list of theme files. Look for your Astra Child Theme’s functions.php file. It should be located in the theme’s directory.
- Click on the “functions.php” file to open it for editing.
- Once you have the functions.php file open, you can add the following code snippet at the end of the file.
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
return $tabs;
}
- After adding the code snippet, make sure to save your changes. Simply click the “Update File” button at the bottom of the editing window.
This code will reorder the product tabs’ priority, making the “Reviews” tab the first tab to be displayed and the “Description” tab the second.
Now that you’ve added and saved the code, you can go to any product page on your WooCommerce store to see the “Review” tab set as the default active tab. This change will encourage customers to read and leave reviews, potentially boosting trust and sales on your site.
By following the steps outlined in this document and adding the provided code snippet to your Astra Child Theme’s functions.php file, you can easily make this adjustment.
Your online store will benefit from increased visibility of product reviews, which can lead to higher conversion rates and customer satisfaction.
Note:
We have documentation on how to add custom codes. This document will assist you in better understanding it. Here’s the link https://wpastra.com/docs/add-custom-php-code/.