Add custom field on admin dashboard comments / reviews

I hope someone can shine me some light with regards to the problem I'm solving.

Currently we can add comments / reviews on woocommerce products - via dashboard using this form:

I can add a default rating value for the comment meta with this:

function add_custom_comment_field( $comment_id ) {
    add_comment_meta( $comment_id, 'rating', 5 );
}
 
add_action( 'comment_post', 'add_custom_comment_field' );

However I would only like to run that action when a comment is posted via dashboard for a woocommerce product. And also show this field rating on the add comment form rather than hardcoding the value of the meta_key to '5'

Topic comment-meta php hooks comments Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.