WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Schemas

ProductCategorySchema::get_category_review_count() protected WC 1.0

Get total number of reviews for products in a category.

{} It's a method of the class: ProductCategorySchema{}

No Hooks.

Return

Int.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_category_review_count( $term );
$term(\WP_Term) (required)
Term object.

Code of ProductCategorySchema::get_category_review_count() WC 5.7.1

protected function get_category_review_count( $term ) {
	global $wpdb;

	$products_of_category_sql = $wpdb->prepare(
		"SELECT SUM( DISTINCT comment_count) as review_count
		FROM {$wpdb->posts} AS posts
		INNER JOIN {$wpdb->term_relationships} AS term_relationships ON posts.ID = term_relationships.object_id
		WHERE term_relationships.term_taxonomy_id=%d",
		$term->term_id
	);

	$review_count = $wpdb->get_var( $products_of_category_sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared

	return (int) $review_count;
}