WC_Comments::check_comment_rating( array $comment_data )

Validate the comment ratings.


Description Description


Parameters Parameters

$comment_data

(Required) Comment data.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/class-wc-comments.php

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


Top ↑

User Contributed Notes User Contributed Notes

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