Add additional field in woocommerce comment form

Adding title field in woocommerce comment form.
add_action( ‘comment_post’, ‘save_comment_meta_data’ );
function save_comment_meta_data( $comment_id ) {

if ( ( isset( $_POST[‘review_title_field’] ) ) && ( $_POST[‘review_title_field’] != ”) )
$title = wp_filter_nohtml_kses($_POST[‘review_title_field’]);
add_comment_meta( $comment_id, ‘review_title_field’, $title );

}

add_filter( ‘comment_text’, ‘modify_comment’);
function modify_comment( $text ){
$plugin_url_path = WP_PLUGIN_URL;
if( $commenttitle = get_comment_meta( get_comment_ID(), ‘review_title_field’, true ) ) {
$commenttitle = ‘

‘ . esc_attr( $commenttitle ) . ‘

‘;
$text = $commenttitle . $text;
}
return $text;

}

Woocommerce product review sorting

You can use this filter to sorting woocommerce product page review.

add_filter( ‘woocommerce_product_review_list_args’, ‘newest_reviews_first’ );
function newest_reviews_first($args) {
if($_GET[‘orderby’] ==”rating” && $_GET[‘order’] == ‘desc’){
$args[‘reverse_top_level’] = true;
}elseif($_GET[‘orderby’] ==”rating” && $_GET[‘order’] == ‘asc’){
$args[‘reverse_top_level’] = false;
}else{
$args[‘reverse_top_level’] = true;
}
return $args;
}