Description: The following article mainly focuses on the key point of shopify login, which shows you an easy way to create a custom login page. Howtoshopify.com is a resource for online tutorials of the popular commerce solution.
Let me show you an easy way to create a custom login page, that one shows the login button when they don’t log in, when they login, it shows a logout button so that you can log back out, it switches back and forth, I’ve created a division with a little button on it at the top right hand corner of my website that’s called login.
I did that by going into my own section and going to my theme template editor, then going to my theme liquid because I wanted it to show up on every page, then I have a couple of divisions that I’ve added in here, one being account where that division is.
I have some styles that I’ve put on this to make it look the way I want it, what I’m going to do is to open this up a little bit, we can go and put the statement in here, we’re going to check if the person is authenticated and if they are authenticated.
Then it shows the logout button, if they’re not authenticated and they haven’t logged in yet, it shows the login button, so I’ve got the code that I’ve written, I’ll copy and paste that in, then I’ll go through it and show you how we do it.
Here’s the code, copy that, go back over to the theme template, we’re going to place that in here, the way it works is a simple if-else statement, if shop customer account is enabled, we want it to show the logout button, so we want to do it in reverse.
If they have logged in, you got to give them a way to get out, if they’ve not logged in, we got to show them a way to get in, if shop customer accounts underscore enabled and customer, give us a reference of account logout, this is the standard Shopify address for logout, anytime you link to this, it’ll log your person out automatically.
The second one here is the login, if you redirect them to this login, it’ll take you to the login customer template liquid that’s over here which you can style and make that look nice, so we’re going to do that, hit save, once that template has been saved, we can hop back over to our market page. I’m going to clean this up a little bit here, I like to have my stuff all formatted nicely.
If I go to login, I get the customer login, I can log in with my username and password, once I log in, I get this nice beautiful logout button, it redirects me to the customer control panel, I can click the logout button and it will log me back out again, that’s all.