at a job interview recently I was in a different part of town stopping at a coffee house and I asked while buying something (etiquette) if I could use the restroom and what I needed to do to do so. I was literally blown away when they said: just walk right in. What? No code? No key? I was in shock, thinking: things are really different in this part of town. I mean it actually took me by surprise.The McDonald's in Stockton, CA had locked bathrooms. For us, simple Midwesterners, it was one of the stranger occurrences in CA.
So yea I think who really thinks coffee house restrooms are open to everyone and yes if you ask they probably will give you the key or the code, even if you don't make a purchase (but then this depends - it's easy if you look middle class like me).