WooCommerce reviews tab not showing
When WooCommerce product reviews tab is not showing up on the product page it may be due to multiple possible reasons.
WooCommerce options
First place to check is WooCommerce product options, located at WordPress admin dashboard -> WooCommerce -> Settings -> Products -> Reviews -> Enable reviews
Product metabox options
Reviews still not showing up? Make sure that reviews are enabled for the individual product in the Product data metabox.
The Product data metabox is on the page where you edit a Product, usually right below the main text editor. If it’s not visible for you, make sure that Product data checkbox is checked under the Screen Options in the top right corner.
Enabling the metabox option by default
Remembering to check the Enable reviews checkbox every time you create a new product can be hard. Why isn’t it enabled by default? That’s because it’s controlled by the WordPress option: Settings -> Discussion -> Default article settings -> Allow people to post comments on new articles.
When that option is not enabled then new WooCommerce products won’t have their reviews enabled by default either.
It says below the setting “These settings may be overridden for individual articles.”, here’s how to actually do that.
The option name of this setting is default_comment_status
and while it can be retrieved using get_option('default_comment_status')
, it is actually retrieved using a function get_default_comment_status($post_type, $comment_type)
that includes some additional logic as well as a get_default_comment_status
filter:
<?php
function get_default_comment_status( $post_type = 'post', $comment_type = 'comment' ) {
...
/**
* Filters the default comment status for the given post type.
*
* @since 4.3.0
*
* @param string $status Default status for the given post type,
* either 'open' or 'closed'.
* @param string $post_type Post type. Default is `post`.
* @param string $comment_type Type of comment. Default is `comment`.
*/
return apply_filters( 'get_default_comment_status', $status, $post_type, $comment_type );
}
So it’s possible to add some custom code to your child theme’s functions.php
that utilizes that filter to enable comments (reviews) for WooCommerce products by default without enabling comments on posts or pages as well:
<?php
add_filter('get_default_comment_status', function($status, $post_type) {
if($post_type === 'product') {
return 'open';
}
return $status;
}, 10, 2);
Enabling reviews for all old products
All your old products will still have their reviews disabled, since they used the default value provided to them at the time of their creation. You can enable reviews individually one by one or run some code that does it all at once.
Here’s some code you can add to your child theme’s functions.php
to enable reviews for all products at once:
<?php
/**
* Enable reviews for all WC Products.
*/
add_action('admin_init', function() {
$updated = 0;
$query = new \WP_Query([
'post_type' => 'product',
'posts_per_page' => -1,
'comment_status' => 'closed',
]);
if($query->have_posts()) {
while($query->have_posts()) {
$query->the_post();
if(wp_update_post([
'ID' => get_the_ID(),
'comment_status' => 'open',
])) {
$updated++;
}
}
wp_reset_postdata();
}
add_action('admin_notices', function() use ($updated) {
printf(
'<div class="notice notice-info is-dismissible"><p>Enabled reviews for %d products.</p></div>',
(int)$updated
);
});
});
After adding this code to your child theme’s functions.php
you should visit your admin dashboard and see a notice informing you how many products were successfully updated. You can reload the page and the number should now be 0. After that you should remove or comment out the code, since it will keep outputting a notice and making a query on every admin page load.
Your theme may not support reviews
If you still can’t enable the reviews, try temporarily switching to a default WordPress theme, such as Twenty Fifteen. When you see that reviews show up with another theme then you can contact your theme developer to find out why their theme doesn’t show them.
Other filters or plugins may be the cause
You can try disabling all plugins except for WooCommerce to see if any of them may be preventing the reviews from showing up.
The tabs that should include a Reviews tab are rendered in a WooCommerce template file /single-product/tabs/tabs.php
. The file includes a filter for retrieving the tabs it should render:
<?php
/**
* Filter tabs and allow third parties to add their own.
*
* Each tab is an array containing title, callback and priority.
* @see woocommerce_default_product_tabs()
*/
$tabs = apply_filters('woocommerce_product_tabs', []);
Any plugins or custom code in your child theme’s functions.php
could be altering it.