I'm trying to display field values within a field collection for a commerce product. In my product template file I'm simply outputting {{ product.field_components }} then using a separate field template file to try to output each value.

Previously I've used something like the following when theming a content type which works:

{%- for item in items -%}
<div class="component_name">
   {{ item.content['#field_collection_item'].field_component_name.value }}
<div class="component_description">                      
   {{ item.content['#field_collection_item'].field_component_description.value|raw }} 
{%- endfor -%}

However, on my product page this doesn't work. The field template twig file is rendering OK, so I must be using incorrect twig syntax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.