我正在开发一个 Shopify 主题应用程序,它要求我从 shop.metafields 加载配置选项,并将它们用作架构标签中的可选选项。我尝试使用 for 循环在模式标记内生成选项数组,但这似乎不是正确的方法。这是我的代码的简化版本:
{% assign optionsArray = shop.metafields.global.convertcart_blockIds %};
{% schema %}
{
"name": "Recommended Products",
"tag": "section",
"target": "section",
"settings": [
{
"type": "richtext",
"id": "heading",
"label": "Heading"
}, {
"type": "select",
"id": "blockId",
"label": "Block ID",
"info": "Select an option",
"options": [{% for option in optionsArray %}
{
"value": "{{ option }}",
"label": "{{ option }}"
}{% unless forloop.last %},
{% endunless %}{% endfor %}]
}
]
}
{% endschema %}
我已经尝试在脚本标签中构建选项数组,但仍然无法在模式中使用该选项数组。有人可以帮我弄清楚如何从 shop.metafields 正确加载配置选项并将它们用作模式标记中的可选选项吗?对此的任何帮助或指示将不胜感激。谢谢!