Use availability of a referenced product in metaobject page template?

Topic summary

Problem: A user needed to conditionally display a button on a metaobject page template based on whether a referenced product (stored in a “product” type field) is available.

Initial Issue: Using {{ metaobject.related_product }} returned only the product’s GID, not the full product object needed to check availability.

Solution: Use .value to access the actual product object from the metafield reference:

{% if metaobject.related_product.value.available %}
  Display button
{% endif %}

Key Points:

  • .value converts the metafield reference into a usable object with accessible properties
  • The syntax is "true" is not valid in Liquid; use the property directly in conditionals
  • The user had previously tried .value but placed it incorrectly after .available instead of before

Status: Resolved. The user confirmed the solution worked.

Summarized with AI on October 28. AI used: claude-sonnet-4-5-20250929.

I’m pretty new to all of this, apologies if this is a dumb question.

Let’s say I’ve got a metaobject definition that includes a field of the “product” type, called “related_product”. On each entry, I select the related product. On the page template for that metaobject, I want to display a button only if that referenced product is available.

In a custom liquid element, I’m finding that

{{ metaobject.related_product }}

kicks out the gid of the related product I selected on that entry. Great, so it’s seeing that product

But I was hoping to do something like

{% if metaobject.related_product.available is “true” %}

Display button

{% endif %}

But can’t seem to get anything like that to work. Any way to make something like that work?

Why not use metafields for this? Just asking.

Not sure but May be using metafields you can get more than gid so other info of the product.

You need to use .value to get actual product object from the metafield reference:

https://shopify.dev/docs/api/liquid/objects/metafield

{% if metaobject.related_product.value.available %}

Display button

{% endif %}

is “true” is not a thing in Liquid.

1 Like

AHHHhhhh, thanks so much. I had already tried using .value but I had put it after .available

Basically, .value makes an object out of reference.

So you use it on the metafield reference and then can use object properties.