Put review tab under description tab

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.

then in the single-product.php template file, any line you want :D, call comments_template() function. If you wish to have reviews tab in specific places, for example after "product tabs" and before "related products", do it with hooks:

add_action( 'woocommerce_after_single_product_summary', '_show_reviews', 15 );
function _show_reviews() {
  comments_template();
}

Show ‘reviews’ tab as the first tab among ‘description’ and ‘additional information’ tabs on a WooCommerce website to give more visibility to reviews. We have already seen the different approach for more reviews visibility by showing reviews separately out of the tabs section. Now, let move the ‘reviews’ tab position in the tabs section on WooCommerce product pages.

Preview: Before and After

Put review tab under description tab

PHP Snippets: Move Reviews Tab

In the WordPress Dashboard, go to Appearance > Theme Editor and open the functions.php file. Add the following code at the end.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

add_filter( 'woocommerce_product_tabs', 'wpd_wc_move_product_review_tab', 1005 );

/**

* Move Reviews tab before Description tab

*

* @param array $tabs Array of tabs.

* @return array

*/

function wpd_wc_move_product_review_tab( $tabs ) {

global $product, $post;

$new_tabs \= array();

if ( comments_open() ) {

$new_tabs['reviews'] \= $tabs['reviews'];

unset( $tabs['reviews'] );

if ( $post-\>post_content ) {

$new_tabs['description'] \= $tabs['description'];

unset( $tabs['description'] );

}

if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {

$new_tabs['additional_information'] = $tabs['additional_information'];

unset( $tabs['additional_information'] );

}

$tabs \= array_merge( $new_tabs, $tabs );

}

return $tabs;

}

The Code Explanation

You can filter (add/edit/delete) the existing tabs with the woocommerce_product_tabs filter. First, I am creating a new tabs array variable and then checking if reviews form is open for a product. If reviews form is open, then we are re-positioning specific tabs.