skip to Main Content

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


  1. 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

    Login or Signup to reply.
  2. 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 %}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search