Is it possible in Shopify to get the email address of the currently logged in user via JS.
Unfortunately I can only find customerId
Is it possible in Shopify to get the email address of the currently logged in user via JS.
Unfortunately I can only find customerId
2
Answers
You can try this. It checks if the customer is logged in and loads the email.
{% if customer %}<script>var cust_email = '{{ customer.email }}'</script>{% endif %}
More on customer fields – The customer object
You cannot directly get customer email in (.js) file, it should be either (.js.liquid) or (.liquid) file.
Although (.js.liquid) file works same as (.js) file, if you still want to get email id of logged user in (.js) file you need to write below code in relative (.liquid) or (.js.liquid) file
For (.liquid) file
For (.js.liquid) file