2

Currently I can get custom fields all or none. Like this

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

but what if i want to call just one of them by id or name like the below. Is there a way to do that with stencil or otherwise?

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

Omar
  • 2,726
  • 2
  • 32
  • 65

2 Answers2

1

You can use the existing {{if}} helper to accomplish this

{{#if display_name '===' 'material'}}
    {{#each product.custom_fields}}
        {{id}} : {{name}} : {{value}}   
    {{/each}
{{/if}}
Alyss
  • 1,866
  • 1
  • 13
  • 27
1

You can select a list item by id. {{product.custom_fields.id.4.name}}, however, if you want to select by name you'll need to implement a conditional as @alyss suggested.

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

Community
  • 1
  • 1
Xenph Yan
  • 83,019
  • 16
  • 48
  • 55