Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hello all,
My client has 2 stores, one for production and one for development.
I am trying to get 'harmonized_system_code' from Storefront API, example:
https://{{store}}/products/{{ product.handle }}?variant={{ product.id }}&view=metafields
I am getting the right data from production store, but in development store I'm getting a JSON parse error since the request is getting the page's source code instead of a JSON code ( I am doing this to ajaxify adding to cart )
While debugging I found out that the link redirects to the product's page.
any idea?
Thanks in advance
Solved! Go to the solution
This is an accepted solution.
I'm not 100% sure on the need here but let's walk through that url. It gives clues.
this...
https://{{store}}/products/{{ product.handle }}?variant={{ product.id }}&view=metafields
... is built up with liquid.
We can see that it will make url like:
https://some-totally-fake-shop.com/products/some-handle?variant=123456&view=metafields
Does the dev shop have that alt template in place?
Got an example to share?
This is an accepted solution.
I'm not 100% sure on the need here but let's walk through that url. It gives clues.
this...
https://{{store}}/products/{{ product.handle }}?variant={{ product.id }}&view=metafields
... is built up with liquid.
We can see that it will make url like:
https://some-totally-fake-shop.com/products/some-handle?variant=123456&view=metafields
Does the dev shop have that alt template in place?
Got an example to share?
I got the key problem from your reply, sir.
Thank you, the dev store's products do not have metafields, and that's what missing and why it redirects to the product page.
thank you