Ad

Get Email Of Currently Logged In User

- 1 answer

Is it possible in Shopify to get the email address of the currently logged in user via JS.

Unfortunately I can only find customerId

Ad

Answer

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

{% if customer %}<script>var customer_email = '{{ customer.email }}'</script>{% endif %}

For (.js.liquid) file

{% if customer %}var customer_email = '{{ customer.email }}'{% endif %}
Ad
source: stackoverflow.com
Ad