Tested and works on Woocommerce product category archive pages…
$loop = new WP_Query( array(
'post_type' => 'product',
'post_status' => 'publish',
'posts_per_page' => 5,
'tax_query' => array( array(
'taxonomy' => 'product_cat',
'field' => 'slug', // Or 'term_id' or 'name'
'terms' => get_query_var( 'product_cat' ), // A slug term
// 'include_children' => false // or true (optional)
)),
'orderby' => 'rand'
) );