Metafields : using multiple elements in each key

Highlighted
New Member
2 0 1

Hi Shopify community, 

For my shop I'm trying to use metafields in order to display different possible options for each product. 
Basically a product on my shop is a person and each person is going to offer multiple session types that I'd like to match in order to display something like: 

  • Session 1 title : Session 1 length + Session 1 price
  • Session 2 title : Session 2 length + Session 2 price
  • and so on...

My metafields are set up as follow : 

  • product.metafields.test.name = "Session 1, Session 2, Session 3, Session 4"
  • product.metafields.test.length = "15 minutes, 30 minutes, 30 minutes, 45 minutes"
  • product.metafields.test.price = "10€, 20€, 30€, 35€"

I'm trying to play around with the different filters and arrays but can't find a way to do it properly. You will find below my latest failed attempt and would love your help on this one.

Thanks a lot ! 

Julien

{% assign length = product.metafields.test.length | split: ", " %}
{% assign name = product.metafields.test.name | split: ", " %}   
 {% assign price = product.metafields.test.price | split: ", " %}       
        <span>{{ name | first }}</span>
       	<span>{{ length | first }}</span>
       	<span>{{ price | first }}</span>
        <span>{{ name | second }}</span>
       	<span>{{ length | second }}</span>
        <span>{{ price | second }}</span>
...


 

0 Likes