App reviews, troubleshooting, and recommendations
I'm using app embeds and in my liquid file I've a variant id and I wanna find the corresponding product data using that variant_id.
How can I do that?
Thanks!
hi @Wakil_eFoli,
You have access to product data from the product page. In the product page you have access to the product object which has the variants property containing all variants available for that product. You can use a for loop to match the variant you want and show it in the UI.
below is a dummy code for example
{% assign variant_id = "your_variant_id_here" %}
{% for variant in product.variants %}
{% if variant.id == variant_id %}
<h1>{{ variant.title }}</h1>
<p>{{ variant.price}}</p>
<!-- Output any other relevant product data -->
{% endif %}
{% endfor %}
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We 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, 2024