Hi everyone,
I’m working on an embedded app which I used Remix App template and trying to access metafields in a Liquid template. I’ve successfully created metafields in the **abc_app_test** namespace with **json** type, and I can see the metafields being returned correctly when I log the settings object in the console. However, I’m unable to directly access the metafield properties using Liquid dot notation like {{ settings.enableHomepageWidget }}.
Here’s the Liquid code I’m using:
{% assign settings = shop.metafields.abc_app_test.settings %}
<!-- Debugging -->
<script>
console.log('Settings Object:', {{ settings | json }});
</script>
<!-- Trying to access enableHomepageWidget -->
<p>enableHomepageWidget: {{ settings.enableHomepageWidget }}</p>
{% if settings != blank %}
{% assign enableHomepageWidget = settings.enableHomepageWidget %}
{% if template.name == 'index' and enableHomepageWidget == "enabled" %}
<script>console.log('enableHomepageWidget is enabled');</script>
{% endif %}
{% endif %}
Issue:
- I can see the full settings object in the console, and it contains the enableHomepageWidget metafield.
- However, when I try to access {{ settings.enableHomepageWidget }}, nothing is returned.
- I’ve tried accessing {{ settings.enableHomepageWidget.value }} but that didn’t work either.
Despite all these steps, I’m unable to access the specific metafield values in Liquid.
I read the Shopify Documentation and also all of the similar issues posted here before but none of them solved my issue.
Is there something I’m missing with how metafields are accessed in Liquid?
Thanks in advance for any insights!