WC_Comments::get_review_count_for_product( WC_Product $product )
Get product review count for a product (not replies). Please note this is not cached.
Description Description
Parameters Parameters
- $product
-
(Required) Product instance.
Return Return
(int)
Source Source
File: includes/class-wc-comments.php
public static function get_review_count_for_product( &$product ) {
global $wpdb;
$count = $wpdb->get_var(
$wpdb->prepare(
"
SELECT COUNT(*) FROM $wpdb->comments
WHERE comment_parent = 0
AND comment_post_ID = %d
AND comment_approved = '1'
",
$product->get_id()
)
);
return $count;
}
Changelog Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |