Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Whenever I try to reference any metafield namespace (i.e. "inventory") under shop.metafields, the linter activates with error message:
"inventory" is invalid. Replace this variable.
However, I have confirmed that this namespace exists by rendering {{shop.metafields.inventory | json}} to one of my Shopify pages via Custom Liquid.
Why does this happen, and what can I do to access shop.metafields within Flow?
You cannot access metafields that way in Flow. The theme liquid does something special to be able to accept those metafield namespaces and keys in that format. In Flow, you currently need to loop over metafields like:
{%- for mf on shop.metafields -%}
{% if mf.namespace == "my_name" and mf.key == "my_key" %}{{ mf.value }}{% endif %}
{%- endfor -%}
Hello Paul,
Thanks for this solution! However, I think I do not get it to work.
Am I missing something or is it not possible to access custom metafields? See screenshot attached.
Kind regards,
Koen
mf.namespace == "custom" and mf.key == "maten"
That makes a lot more sense, thanks for the prompt reply
We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024