This will redirect the customer the referring url on login to WooCommerce.
function wc_custom_login_redirect() {
// This will redirect the customer the referring url on login to WooCommerce..
$location = $_SERVER['HTTP_REFERER'];
wp_safe_redirect($location);
exit();
}
add_filter('woocommerce_login_redirect', 'wc_custom_login_redirect');