3

Since switching to new Customer Accounts sytem, I can't figure out how to access the currently logged in customer in my theme.

With the old system, the customer id was accessible via {{ customer.id }} in liquid, and __st.cid in JavaScript. This no longer works when using the new Customer Accounts.

What's the best way to access the customer id in a theme with the new system?

See also here: https://community.shopify.com/c/shopify-functions/issue-with-new-customer-accounts-login/m-p/2785423

Expected: {{ customer.id }} and __st.cid return the id of the currently logged in customer, or null of not logged in.

Actual: Both values are undefined when using the new Customer Accounts system

2
  • 1
    Ok, I setup a new Shopify store to test this. I can confirm that I'm getting the customer data properly under new Customer Accounts. I tested in both theme.liquid and in a custom snippet file as shown in the screen recording in the link that you have shared. In both the places I'm getting the customer data. Perhaps you are doing something wrong? Try switching the theme. Commented Jan 17 at 15:19
  • Well, that's unexpected. I switched to legacy login then back to customer accounts, now it works as expected. Not sure if that was a bug in Shopify or in one of the installed apps. Thanks! Commented Jan 18 at 16:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.