WC_Product::get_rating_count( int $value = null )

Get the total amount (COUNT) of ratings, or just the count for one rating e.g. number of 5 star ratings.


Description Description


Parameters Parameters

$value

(Optional) Rating value to get the count for. By default returns the count of all rating values.

Default value: null


Top ↑

Return Return

(int)


Top ↑

Source Source

File: includes/abstracts/abstract-wc-product.php

	public function get_rating_count( $value = null ) {
		$counts = $this->get_rating_counts();

		if ( is_null( $value ) ) {
			return array_sum( $counts );
		} elseif ( isset( $counts[ $value ] ) ) {
			return absint( $counts[ $value ] );
		} else {
			return 0;
		}
	}


Top ↑

User Contributed Notes User Contributed Notes

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