WordPress at Your Fingertips
function is not described

WC_Comments::add_comment_rating() public WC 1.0

Rating field for comments.

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

No Hooks.

Return

null. Nothing.

Usage

$result = WC_Comments::add_comment_rating( $comment_id );
$comment_id(int) (required)
Comment ID.

Code of WC_Comments::add_comment_rating() WC 5.6.0

public static function add_comment_rating( $comment_id ) {
	if ( isset( $_POST['rating'], $_POST['comment_post_ID'] ) && 'product' === get_post_type( absint( $_POST['comment_post_ID'] ) ) ) { // WPCS: input var ok, CSRF ok.
		if ( ! $_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0 ) { // WPCS: input var ok, CSRF ok, sanitization ok.
			return;
		}
		add_comment_meta( $comment_id, 'rating', intval( $_POST['rating'] ), true ); // WPCS: input var ok, CSRF ok.

		$post_id = isset( $_POST['comment_post_ID'] ) ? absint( $_POST['comment_post_ID'] ) : 0; // WPCS: input var ok, CSRF ok.
		if ( $post_id ) {
			self::clear_transients( $post_id );
		}
	}
}