You cant run query based on taxonomy only. You also need to provide the taxonomy term the custom post type post associated with. Change your $args
like below –
$args = array(
'post_type'=> 'products',
'tax_query' => array(
array(
'taxonomy' => 'cosmetics', // your taxonomy
'field' => 'term_id',
'terms' => get_term_by('name', $foo, 'cosmetics')->term_id, // your taxonomy term id or array of id's
)
),
'order' => 'rand',
'showposts' => '4'
);
For more information on WP_Query()
arguments please read this.