Hello, I was trying to get the product.images.variant_ids with liquid but it always shows null, could please help me to get the variant_ids for the product?
Website www.lovwee.com
Thank you~
Hello, I was trying to get the product.images.variant_ids with liquid but it always shows null, could please help me to get the variant_ids for the product?
Website www.lovwee.com
Thank you~
Please use the given code to get product variant ids.
{% for variant in product.variants %}
{{ variant.id }}
{% endfor %}
I want to get it from images.variant_ids and then I want to use for example
{% if image.variant_ids.size > 0 %}
something here
{% endif %}
no, this is the wrong thing because image haven’t variant ids. only product have many type of variants. if you want to get product variant image id then you can use {{ variant.image.id }} in variant loop.
{% for variant in product.variants %}
{{ variant.id }}
{{ variant.image.id }}
{% endfor %}
Got it, Thank you so much for your answers @niraj_patel
Want I want to achieve is to add a CSS class for only the main pictures and all variants, I touch I can achieve it by using images and variants_ids from here because I found in the images the pictures that it’s not included in the variant image it’s empty in variants_ids, I don’t know if you get my point?
is there any other option to achieve that?