Hello,
I have added additional field to registration field i-e customer department as notes. I want to show department name on account page. If I make ajax call to customer api i get the following error. Access to XMLHttpRequest from origin has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. I tried by making the request from another server and returning the response to shopify but i still get same error. How can I print customer notes on account page and make call to customer api?
Thanks
What customer api is that?
Hello, @FaizaBashir ,
Your CORS error tell me your script is trying to access something under a different domain than the site it’s running on. Ajax for security has to have permission to run outside its hosted domain.
You’ll have to use a custom app to grab customer information like that.
Here’s an example on doing that:
https://github.com/phpclassic/php-shopify
In liquid though, you can capture the currently logged in user’s customer object like this
Var customer={};
customer[whatever parameter you want]={{customer.(whichever parameter you want)}};
Here’s more info on that
https://shopify.dev/api/liquid/objects/customer
If you’d like further assistance, please message me.