public static function add_comment_rating($comment_id)
{
if (isset($_POST['rating']) && 'product' === get_post_type($_POST['comment_post_ID'])) {
if (!$_POST['rating'] || $_POST['rating'] > 5 || $_POST['rating'] < 0) {
return;
}
add_comment_meta($comment_id, 'rating', (int) esc_attr($_POST['rating']), true);
}
}