WC_Comments::check_comment_rating()public staticWC 1.0

Validate the comment ratings.

Method of the class: WC_Comments{}

No Hooks.

Return

Array.

Usage

$result = WC_Comments::check_comment_rating( $comment_data );
$comment_data(array) (required)
Comment data.

WC_Comments::check_comment_rating() code WC 8.7.0

public static function check_comment_rating( $comment_data ) {
	// If posting a comment (not trackback etc) and not logged in.
	if ( ! is_admin() && isset( $_POST['comment_post_ID'], $_POST['rating'], $comment_data['comment_type'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) && empty( $_POST['rating'] ) && self::is_default_comment_type( $comment_data['comment_type'] ) && wc_review_ratings_enabled() && wc_review_ratings_required() ) { // WPCS: input var ok, CSRF ok.
		wp_die( esc_html__( 'Please rate the product.', 'woocommerce' ) );
		exit;
	}
	return $comment_data;
}