Personalized checkout and custom promotions with Shopify Scripts
Hi Shopify Community, Please help
I'm currently working on a project where I need to fetch and display metaobjects from a specific folder in Shopify using Liquid. The folder is named "Johnson Controls" under the "Connections" metaobjects.
Despite my efforts, the metaobjects are not being displayed correctly on the page. I've included debug statements to verify the fetched metaobjects, but it still doesn't seem to work.
Here is the code I'm using
<div class="mentor-container">
{% assign connection_name = 'connections' %}
{% assign folder_name = 'Johnson Controls' %}
{% assign metaobjects = shop.metaobjects[connection_name] %}
{% comment %}
Debugging Output: Display all fields of each metaobject
{% endcomment %}
<h2>Debug Information</h2>
<ul>
{% for metaobject in metaobjects %}
<li>
Name: {{ metaobject.name }}
<ul>
{% for field in metaobject %}
<li>{{ field[0] }}: {{ field[1] }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
{% assign filtered_metaobjects = metaobjects | where: 'company', folder_name %}
{% if filtered_metaobjects.size > 0 %}
<meta name="description" content="{{ filtered_metaobjects.first.description | escape }}">
{% render 'meta-tags' %}
{% else %}
<p>No metaobjects found for the specified company.</p>
{% endif %}
{% for metaobject in filtered_metaobjects %}
<div class="mentor-card" onclick="openVideo('{{ metaobject.vimeo_1.value }}')">
{% if metaobject.photo.value %}
<img src="{{ metaobject.photo.value | image_url: width: 100 | image_tag }}" alt="{{ metaobject.name.value }}">
{% else %}
<!-- Debugging: Display message if photo is missing -->
<p>No photo available for {{ metaobject.name.value }}</p>
{% endif %}
{% if metaobject.name.value %}
<h3>{{ metaobject.name.value }}</h3>
{% endif %}
{% if metaobject.job.value %}
<p>{{ metaobject.job.value }}</p>
{% endif %}
</div>
{% endfor %}
</div>
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024