I recently came across a website that sell random market products but because they are a small startup their services are not yet available everywhere in my city. To avoid problems due to their limited service area, they ask you to register and give them your zip code so they can check if they are currently working on your region. Needless to say many users will have to complete the register process only to find out that the service is not available, which is very annoying. Also a "buy-then-register" approach is probably even a worse solution for their design problem.
Anyway, I told you this small story only to ask: when your user must register/login to be able to use your website due to company's lack of service in some regions, what is the best approach to avoid unnecessary frustration and avoid users from leaving your website due to the login wall?