我们在这里使用 Shopify 的部分渲染 API 来动态替换产品块。
部分渲染 API 位于:https://shopify.dev/docs/api/section-rendering
这些部分似乎渲染得很好,但它没有渲染添加到部分架构中的任何块。
你能建议一下,这里出了什么问题吗?
部分架构:
{% schema %}
{
"name": "Reviews",
"class": "review-slider",
"settings": [
{
"type": "checkbox",
"id": "enable",
"label": "Uncheck to hide the section",
"default": true
},
],
"blocks": [
{
"type": "text",
"name": "Review",
"settings": [
{
"type": "text",
"id": "username",
"label": "User Name"
},
{
"type": "text",
"id": "review",
"label": "Review"
},
{
"type": "url",
"id": "link",
"label": "Add link"
},
{
"type": "text",
"id": "btntext",
"label": "Button Label"
}
]
}
],
"presets": [
{
"name": "Review Slider"
}
]
}
API 调用:向 /products/
刚刚遇到同样的问题。我有一个部分已手动添加到 JSON 模板,并且认为我可以只使用在 JSON 中使用的 ID。但是,我需要按照文档使用完整的 ID(包括模板标识符)here。
我的部分称为
cart
,当我将其添加到我的 JSON 模板时,我使用了 ID cart
:
"sections": {
"cart": {
"type": "cart",
...
}
}
我认为这意味着我可以使用 ID
cart
从剖面渲染 API 请求它。但是,此请求仅返回默认内容。再次检查文档后检查渲染的模板表明我需要使用完整的模板+部分 ID,在我的例子中是 template--22672155574566__cart
。