Retrieve data from list.product_reference array

Hi,

unfortunately, I have been a bit stuck on retrieving the data from a list.product_reference. I am trying to create page for an assembled product kit and link the individual products, that make up this kit separately for the customer to look at the detailed specifications.

{% assign x = product.metafields.custom.kits_specification_reference.value['components_products'] %}

{{x}} 
> returns ["gid://shopify/Product/9413686952256","gid://shopify/Product/9373496803648"]

{%for xx in x%}
{{xx}} > returns null
{{xx[0]}} > returns null
{{xx.value}} > returns null
{{xx[0].value}} > returns null

{%endfor%}

I have reviewed the docs, tried different filters, reviewed several communities posts but I cannot figure it out.

I appreciate the help :slightly_smiling_face:

Hi,

At new page, you can utilize shopify liquid to loop through product handles or ids, retrieve data, and display each product’s details with links to their respective pages.

Code example

{% assign product_handles = "product-handle-1, product-handle-2, product-handle-3" | split: ", " %}

{% for handle in product_handles %}
  {% assign product = all_products[handle] %}
  
  
    ## {{ product.title }}
    

{{ product.description }}

    
    
      {% for variant in product.variants %}
        - {{ variant.title }} - {{ variant.price }}
      {% endfor %}
    

    
    View Product
  

{% endfor %}

Hope this will help or if still you need help, use signature to contact us .

Hi thanks you for your help.

Unfortunatley, I am not having any success like this. I cannot define the handles as they are located in a referenced metaobject, with of type list. I am trying to access this list/array through the linked product.metafield but I get stuck and cannot figure out how to read the object itself.

My ultimate goal is to provide the reader/customer with a list of url’s of the products the kit has been made of as each of them have more detailed specifications.

Add more value

product.metafields.custom.kits_specification_reference.value['components_products'] 

to

product.metafields.custom.kits_specification_reference.value['components_products'].value

One of the annoying parts of the syntax is having to keep using value even though you’ve already got the value, and in this case it’s still singular value and not plural values even though it’s a list /shrug.

{% assign x = product.metafields.custom.kits_specification_reference

{% for xx in x.value %}
   ..
{% endfor %}