All_products with varible json handle not working.

Solved
Sam8484
New Member
2 0 0

Hi there,

I'm having some difficulties with receiving a product title when I use a variable as handle. 

 

<ul>
  {% assign colorProduct = product.metafields.custom.json.a %}
<li>{{colorProduct}}:{{ all_products[colorProduct].title }}</li>
</ul>

 

Output:

skinny-enkel-jeans-roxanne-|-lichtblauw:

---

I am able to output the handle as HTML but not as a variable. Could anybody tell me what I'm doing wrong? 

0 Likes
Ninthony
Shopify Partner
1634 224 612

This is an accepted solution.

Is that actually the product's handle? As far as I know, there should be no special characters in a handle, I see you have a pipe character "|" -- that may be incorrect. Because it looks like you're approaching the output correctly for using {{ all_products[product-handle].title }}

If my solution helped you, please like and accept as solution!
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
Sam8484
New Member
2 0 0

Thank you ninthony! That was it

0 Likes