Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
I need to display a custom gift card image based on the variant selected. I need to display this on the (1) 'Gift card created' email notification and the (2) gift_card.liquid page. Currently, I can not find a method of passing/reading the information in liquid. Please help... this seems like a logical requirement. Note: some variants have a different initial price, so I can not use this information as a reference.
You can refer https://shopify.dev/api/liquid/objects/gift-card#gift_card-product
You can try with: gift_card.product and then get product variants with product.variants, ex: https://shopify.dev/api/liquid/objects/product#product-variants
Hope it helps!
Did you ever get a way to do this ?
I see I'm late, but if anyone's still looking for a way to do this here's how I did it.
I added the variant image as a line item property (_variantImage so that customers don't see it) and then read it from gift_card.properties
Hey, I was looking at this today, and I managed to get a gift card variant image like this:
{% assign defaultImage = 'gift-card/card.svg' | shopify_asset_url %}
{% assign gift_card_product = all_products['gift-card'] %}
{% if gift_card_product %}
{% for variant in gift_card_product.variants %}
{% if variant.price == gift_card.initial_value %}
{% assign image = variant.image | image_url: width: 1024, height: 1024 %}
{% endif %}
{% endfor %}
{% else %}
{% assign image = settings.gc_image | image_url: width: 1024, height: 1024 %}
{% endif %}
I hope this helps someone.