I am using metaobjects and refernce them in certain products. In my cart liquid, I want to loop over the products and find all references to the metaobject. If one is linked to a product in the cart, I need to access additional data in the metaobject.
How can I access the metaobject data in liquid? Or how do I use the generated GIDs?
I am currently finding the metaobject like this:
{% for item in cart.items %} {% if item.product.metafields.custom.object_upsell %} {{ item.product.metafields.custom.object_upsell }} --> here, I get e.g. ["gid://shopify/Metaobject/9076982","gid://shopify/Metaobject/9044214"] {% endif %} {% endfor %}
When I try and loop over the object like this, I get no output at all:
{% assign referencedObjects = item.product.metafields.custom.upsell_to %} {% for object in referencedObjects %} {{ object }} {% endfor %}
I expected to still get an output of the gids, here.
Add "| first" after value try to fetch