Gift Card - Custom Image Based on Variant

Topic summary

A developer needs to display custom gift card images based on the selected variant in both email notifications and the gift_card.liquid template, but cannot find a way to pass/read variant information in Liquid.

Attempted Solutions:

  • Initial suggestion to use gift_card.product and product.variants from Shopify’s Liquid API was unsuccessful
  • One user added variant image as a hidden line item property (_variantImage) and retrieved it via gift_card.properties
  • Another solution matches variants by comparing variant.price with gift_card.initial_value, though the original poster noted price cannot be used as a reliable reference since some variants share the same initial price

Current Status:
The discussion remains open with multiple workarounds proposed but no definitive solution that addresses the original constraint about variants having identical prices. The core challenge is accessing variant-specific data within Liquid templates for gift cards.

Summarized with AI on October 31. AI used: claude-sonnet-4-5-20250929.

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.

1 Like

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!

Nope it does not

1 Like

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.

Hey @TanjaCodi ,
what did you placed in the all_products[‘gift-card’] ? And I think this is static solution. Plus in loop you are checking condition based on price it can happen that one or more product’s variant has some price. What will happen then?
Please let me know if I have misunderstood this or is there any other jack to make this work as I am desperately looking for.
Thanks.