How do I identify guest users inside the checkout.liquid template?

nardoyala
Shopify Partner
3 0 0

Do you know if there's a way of identifying guest users in the checkout page with Liquid?

Normally, you can check if a user exists by checking if this object is blank: {{ customer }}, but on the checkout page you have a different customer object {{ checkout.customer }}.

I believe that the second one is never blank. Is that correct? Do you know if I can use the first one inside the checkout.liquid template?

The reason is that I'm trying to add a "Create an account" message for guest users on the order status page, I would render that message only if the customer is a guest customer.

So my code will look like this:

{{ unless customer }}
<-- Custom code for users that do not have an account -->
{{ endunless }}


Many thanks.

Replies 4 (4)

HunkyBill
Shopify Expert
4851 60 554

Is this not already part of checkout? A guest chooses to not have an account. So they provide their customer information for the purchase, pay and move on. On the other hand, customers are offered the make the info persistant in checkout if they did not create an account or login. So what would be the point of your check? It just dupes what is already on offer. ???

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
nardoyala
Shopify Partner
3 0 0

Hi @HunkyBill, thanks for your reply.

I don't fully understand what you refer to when saying that is already part of the checkout. What I want to do is to identify if a user is a guest user or a user that is already registered on the site.

The point of doing that is that then I can only show the "Create an account" call to action to guest users. Why do you think this doesn't make sense? I don't understand how this dupes what is already on offer.

HunkyBill
Shopify Expert
4851 60 554

My point is, you do not need to call attention to them to create an account in checkout. First off, that would be annoying, and secondly, they can do that already simply with a checkbox. That was my point. Obviously, you are seeing things different, but I highly doubt you're going to find anything in Liquid to satisfy your needs. Checkout is 99.9999 percent set in stone. No one gets to tinker with it.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
nardoyala
Shopify Partner
3 0 0

Hi @HunkyBill, thanks for taking the time to elaborate a bit more.

I understand your point, but independently of whether having text inviting guest users to create an account is annoying or not, I believe my question is still relevant.

Shopify has plenty of liquid objects you can use on the checkout page, here you can see a reference to them in their docs.

I understand you can't make many modifications in the checkout.liquid template, but appending a text and a link with JavaScript in the order status page is totally doable, I just want to have access to a boolean for appending that based on if the client is a guest user or not.

That's the main point of my question, whether I can use or not the same liquid object I use for other templates: {{ customer }}.