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.


Top ↑

Return Return

(int)


Top ↑

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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.