Balvan
March 6, 2025, 10:32am
1
The metafield is type Product (list of products).
I have tried {% for product in product.metafields.custom.upsell_styled_with.values %} (plural) too, but still no output.
Here are 3 examples of different outputs. Actually, first 2 have outputs, but the 3rd doesn’t even run the loop, as there is no p tag in third case:
Output:
Hi @Balvan
I think the reason you don’t see any output in your for loop
, because you are trying to iterate through a single value.
Your variable styled_with_products
is not an abject.
by doing this
{% assign styled_with_products = product.metafields.custom.upsell_styled_with.value
you just say let’s store a single value in styled_with_products
.
Does it make sense?
2 Likes
curzey
March 6, 2025, 8:39pm
3
I think @Eugene_Kasimov is right.
This works for me:
{% for product in product.metafields.custom.bundle_products.value %}
...{{ product.title }}...
{%- endfor -%}
which is identical - just without assigning it first.
Balvan
March 7, 2025, 2:16pm
4
@curzey @Eugene_Kasimov
The client has actually chosen archived products in the metafield so that was the issue.
Thank you for your suggestions!
2 Likes
curzey
March 7, 2025, 3:01pm
5
That’s a struggle.
Archived products and b2b catalogs where not all customers has access to specific products.