how to access values in array of object in custom liquid shopify, this array of object is added in metafields of product
how to access values in array of object in custom liquid shopify, this array of object is added in metafields of product
I have added an array of object in product metafields like below:
const response = await client.query({
data: {
"query": `mutation updateProductMetafields($input: ProductInput!) {
productUpdate(input: $input) {
product {
id
metafields(first: 3) {
edges {
node {
id
namespace
key
value
}
}
}
}
userErrors {
message
field
}
}
}`,
"variables": {
"input": {
"metafields": [
{
"namespace": "my_field",
"key": "faq",
"type": "json",
"value": "{\"objects\": [{\"question\": \"test 1\", \"answer\": \"yes I'm test 1\"}, {\"question\": \"test 2\", \"answer\": \"yes I'm test 2\"}] }"
}
],
"id": "gid://shopify/Product/435353534"
}
},
}
});
Now I want to access these in my custom liquid, I tried accessing it but nothing is shown
{% assign product_metafields = product.metafields.my_field.faq -%}
{% for object in product_metafields.objects %}
<p>Question: {{ object.question }}</p>
<p>Answer: {{ object.answer }}</p>
{% endfor %}
Kindly tell me where the issue is.
Turbo Multi-language Translator
Make the better internet purchasing globaly
Turbosify SEO Speed Booster
5.0 (7)•Free plan available
Get better conversions by improving store loading speed
Installed
Turbo Multi-language Chat - AI Customer service in one hand