You can use the filter “login_redirect”, in the function to create you’ll need to verify the role of the user, check for the order and get product id in the order. Then you’ll be able to get the permalink for this product and redirect the user.
A little example, as you told that they can purchase only one product, this can work,
add_filter( 'login_redirect', 'login_customer_redirect', 10, 3 );
function login_customer_redirect($redirect_to, $request, $user){
if ( isset( $user->roles ) && is_array( $user->roles ) ) {
if ( in_array( 'administrator', $user->roles ) ) {
// redirect them to the default place
return $redirect_to;
}
//check for customers
elseif ( in_array( 'customer', $user->roles ) ) {
$user_order = new WC_Order($user->ID);
$items = $user_order->get_items();
foreach ($items as $item) {
$product_id = $item['product_id'];
}
$redirect_to = get_permalink($product_id);
return $redirect_to;
} else {
return home_url();
}
} else {
return $redirect_to;
}
}