The Not Enrolled Redirect module adds a field to the Edit Course screen (in the Settings tab of the course in LearnDash 3.x) that enables you to specify a URL that users will be redirected to if they attempt to access the course but are not enrolled. The redirect will apply to all logged-out users, as well as logged-in users that are not enrolled. The redirect will not affect Administrator users.
This is particularly useful if you want to redirect non-enrolled users to a sales or purchase page rather than the standard course page which may not be optimized for course sales.
As of version 3.2.1, the Redirect URL field accepts shortcodes.