'Can I hide a section if there are no reviews in Woocomemerce?
In woocommerce, if a product has no reviews, there is a section I call "ID: #reviewssummary" and I want to hide this section within the product page.
I want to do this because I only have people who buy products leave comments using the "my account" page and not in the product page.
Solution 1:[1]
There are multiple ways you check this:
Using get_comments()
$args = array ('post_type' => 'product', 'post_id' => get_the_ID());
$comments = get_comments( $args );
if(empty($comments)) {
echo 'No Reviews Yet';
}
Another way $product->get_review_count()
global $product;
if ($product && $product->get_review_count() === 0) {
echo 'No Reviews Yet';
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mehedi Foysal |
