product_ref and .value fixed it for me. for anyone who is similarly frustrated.
{% assign featured_ingredients = product_ref.metafields.custom.featured_ingredients.value %}
{% if ingredient %}
No ingredients found.
{% endif %}Goal: Iterate a Metaobject list (featured_ingredients) for each product inside a loop over a Product List metafield (pair_with), to output each ingredient’s name and icon. Inside the loop/snippet, attempts returned null despite working outside.
Proposed fix: Assign featured_ingredients inside the related-products loop and reference each product’s metafield (product.metafields.custom.featured_ingredients), then iterate and resolve each entry via the metaobject filter.
Final working solution: In the rendered snippet, the correct product variable is product_ref (passed to the snippet), not product. The list also must be dereferenced with .value. Working assignment:
Notes:
Status: Resolved. OP confirms product_ref plus .value fixed the issue; alternate suggestion did not solve their specific setup.
product_ref and .value fixed it for me. for anyone who is similarly frustrated.
{% assign featured_ingredients = product_ref.metafields.custom.featured_ingredients.value %}
{% if ingredient %}
No ingredients found.
{% endif %}