woocommerce list product by id

You should use “tax query” like this:

$args = array( 
    'post_type' => 'product', 
    'posts_per_page' => 5,
    'tax_query' => array(
        array(
            'taxonomy' => 'product_cat',
            'terms'    => 5,
        ),
    ),
);

Using taxonomy name (product_cat) as WP_Query parameter is deprecated.