Order status page: How to tell if someone is logged in?

Bjorn_Forsberg_
Shopify Partner
303 4 70

Hey folks,

 

Not sure if this is the correct category for this question, but it has an impact on other apps using Checkout Scripts.

 

One of my apps adds a button to the Shopify Order Status page (previously the Thank You page). That page can be accessed later by customers to view the status of their order. In some cases, they will be asked to input their email and order number, before sensitive order data like name and address are shown:

 

Thank_you__-_Willys-Hifi_Ltd_-_Checkout.png

 

However, the issue is that Shopify still renders all "checkout scripts" on the non-logged in version of the page. In my case, this means that the button to download a receipt/invoice for their purchase is also accessible without the person logging in first.

 

Question: How can I check (in the checkout script) if the user is logged in or not? For privacy reasons, we'd prefer to only show the button once the person has access to the full details on the page.

 

I've checked all the documentation for Checkout Scripts and there is no mention of the logged out page version anywhere.

 

Many thanks,

Bjorn

Bjorn Forsberg | FORSBERG+two | Award-winning Shopify Apps since 2011
Replies 4 (4)

Alex
Shopify Staff
1561 81 341

I assume you're talking about Shopify Scripts. I'm not super proficient with them since my team specifically doesn't support this kind of implementation, but from the documentation, could you access cart.customer.id? I'd imagine the ID would only be populated in  the event that the cart (and perhaps the checkout) are associated to an existing customer record.

 

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Bjorn_Forsberg_
Shopify Partner
303 4 70

Hey Alex,

 

Thanks for the reply, and apologies if it was not clear. It's not related to Shopify Scripts, but "Additional Scripts" for the checkout thank you page. See this help section of Shopify: https://help.shopify.com/en/manual/orders/status-tracking/order-status-javascript-asset

 

Thanks,

Bjorn

Bjorn Forsberg | FORSBERG+two | Award-winning Shopify Apps since 2011
Alex
Shopify Staff
1561 81 341

This is something I see brought up frequently and the answer that I can give is that at this time there is not a supported method for doing this. At first I thought you could use the customer liquid object, but it looks like that's populated regardless of whether the customer is logged in to the storefront or not on that page.

 

Have you tried making an ajax call to an app proxy route to get the liquid value from there? {{ customer.id }} should be null unless the customer is signed in on that page. A bit hacky but worth a shot. Again, not a supported approach, but just a thought.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Bjorn_Forsberg_
Shopify Partner
303 4 70

Thanks for the reply Alex, and for confirming it's not currently possible 😞 Will try and get creative, so we can only render the button of the person is logged in.

Bjorn Forsberg | FORSBERG+two | Award-winning Shopify Apps since 2011