【问题标题】:Calling a Specific custom_field BigCommerce Stencil调用特定的 custom_field BigCommerce Stencil
【发布时间】:2017-02-23 19:45:17
【问题描述】:

目前我可以全部或没有自定义字段。像这样

{{#each product.custom_fields}} {{ id }} : {{ name }} : {{ value }} {{/each}}

但是如果我只想通过 id 或名称调用其中一个,如下所示。有没有办法用模板或其他方式做到这一点?

{{product.custom_fields.id:4.name}}

【问题讨论】:

    标签: handlebars.js shopify bigcommerce


    【解决方案1】:

    您可以通过 id 选择列表项。 {{product.custom_fields.id.4.name}},但是,如果您想按名称选择,则需要按照 @alyss 的建议实现条件。

    见:How do I access an access array item by index in handlebars?

    【讨论】:

      【解决方案2】:

      您可以使用现有的 {{if}} 助手来完成此操作

      {{#if display_name '===' 'material'}}
          {{#each product.custom_fields}}
              {{id}} : {{name}} : {{value}}   
          {{/each}
      {{/if}}
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-11-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-06-15
        • 1970-01-01
        相关资源
        最近更新 更多