Shopify themes, liquid, logos, and UX
I have a metaobject called beekeeper, which has 4 fields - name, location, profile_image, total_hives. This metaobject is linked to a product via metafield called hive.beekeeper
The issue is that I cannot display meta values. The closes I got was with {{ card_product.metafields.hive.beekeeper }}, where I at least got gid://shopify/Metaobject/72501821775 in response.
I need to display name value. Dawn Theme. Please help
Hello @mybzzfarm ,
Can you please share few screen-shots how and where you created metaobjects?
or a short video ?
Thanks
Hi,
I do apologise I couldn`t reply earlier. Please see screenshots below.
Also, I did make a little bit of progress by using this bit:
{% for beekeeper in shop.metaobjects.beekeeper.values %}
<div class="profile-image-holder">
<img src="{{ beekeeper.profile_image.value }}" alt="{{ beekeeper.name.value }}" class="beekeeper-profile-image" width="30px" height="30px">
</div>
<div class="beekeeper-info">
<p>{{ beekeeper.name.value }}</p>
<p>{{ beekeeper.location.value }}</p>
<p>Total Hives: {{ beekeeper.total_hives.value }}</p>
</div>
{% endfor %}
But of course it iterates and displays all entries, whereas I simply cannot figure out how to better write IF statement to display only entry assigned to the current product (it`s to be displayed on a product card within collection, not on a product page).
Hope you can help me.
Hello. Please try this for all the information show on product collection page.
{% if card_product.metafields.custom.hive.beekeeper %}
{% assign beekeeper = shop.metaobjects.beekeeper[card_product.metafields.custom.hive.beekeeper] %}
{% if beekeeper %}
<div class="profile-image-holder">
{% if beekeeper.profile_image != blank %}
<img src="{{ beekeeper.profile_image | metafield_tag }}" alt="{{ beekeeper.name }}" class="beekeeper-profile-image" width="30px" height="30px">
{% endif %}
</div>
<div class="beekeeper-info">
{% if beekeeper.name != blank %}
<p>{{ beekeeper.name }}</p>
{% endif %}
{% if beekeeper.location != blank %}
<p>{{ beekeeper.location }}</p>
{% endif %}
{% if beekeeper.total_hives != blank %}
<p>Total Hives: {{ beekeeper.total_hives }}</p>
{% endif %}
<!-- Add other beekeeper fields as needed -->
</div>
{% else %}
<!-- Optional: Display a message if the beekeeper is not found -->
<p>Beekeeper information not available.</p>
{% endif %}
{% endif %}
You may use only product instead of card_product for product page.
This is what I`m trying to achieve: every hive is assigned with beekeeper, and I want to display a small icon of a beekeepers profile picture. At the moment, since the loop iterates through all entries, you can only see the latest one, but I need something to define "if this product is assigned with this entry from metafield, then display this info"
Try this for collection cards:
{% if card_product.metafields.custom.hive.beekeeper %}
{% assign beekeeper = shop.metaobjects.beekeeper[card_product.metafields.custom.hive.beekeeper] %}
{% if beekeeper %}
<div class="profile-image-holder">
{% if beekeeper.profile_image != blank %}
<img src="{{ beekeeper.profile_image | metafield_tag }}" alt="{{ beekeeper.name }}" class="beekeeper-profile-image" width="30px" height="30px">
{% endif %}
</div>
{% endif %}
{% endif %}
Hey guys,
I try to display new shopify metaobjects with liquid code.
I would like to show the content of the field "Informationen zu Allergenen". Which could be "Sulfite", "Nuts", "Egg" and so on..
What variable do I need to use to show it in custom liquid inside the customizer?
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey 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, 2024