How to use API's to check if customer is logged in or not and get ID?

DianeDouglas
Tourist
4 0 0

Hi all,

I'm wondering what the best way is to check if a user is logged in or not from within a shopify app. Would love some details on the correct approach. 

  • Can you modify a template to use something like this:

 

{% if customer  %}
// use script tag to make an AJAX call to your app 
{% else %}
// use script tag to make a different AJAX call to your app 
{% endif %}​​

 

  • Is there a webhook to notify your app when a user logs in? 

Once you know a customer has logged in, can you then get their id to use with the graphQL API to look up the Customer object? 

0 Likes