Bug when metafield is type Page Reference and Accept list of values

This does indeed seem like a bug. It appears that while a metafield of type list.product_reference returns a ProductListDrop for its value property, the value of a metafield of type list.page_reference is empty.

I ended up using this workaround:

  • Split up the “gid://shopify…” string into an array that holds all the page IDs
  • Use the global pages object and the where filter to get the page object for each ID

Here’s the code to create a list of pages assigned to a customer via a metafield of type list.page_reference with the namespace custom and the key pages:

{% assign the_pages = customer.metafields.custom.pages | replace: "[", "" | replace: "]", "" | remove: '"' | remove: 'gid://shopify/OnlineStorePage/' | split: "," %}

  {% for the_page in the_pages %}
    {% assign page_id = the_page | times: 1 %}
    {% assign page_obj = pages | where: 'id', page_id | first %}
    - {{ page_obj.title }}
  {% endfor %}

2 Likes