Solved

All_products with varible json handle not working.

Sam8484
Visitor
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? 

Accepted Solution (1)

Ninthony
Shopify Partner
2329 350 1023

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 it and accept it as the 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 😄

View solution in original post

Replies 2 (2)

Ninthony
Shopify Partner
2329 350 1023

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 it and accept it as the 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 😄
Sam8484
Visitor
2 0 0

Thank you ninthony! That was it