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

Gift Card - Custom Image Based on Variant

Gift Card - Custom Image Based on Variant

royn
Shopify Partner
3 0 2

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.

 

 

Replies 5 (5)

LitExtension
Shopify Partner
4963 1010 1192

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!

LitExtension - Shopping Cart Migration Expert
Check out our Shopify migration app to migrate your online store to Shopify
Contact us:
- Email: contact@litextension.com
fdsfsdfsdfsdfsd
Visitor
1 0 1
Nope it does not

jax22
Shopify Partner
5 0 1

Did you ever get a way to do this ? 

pandazaar
Shopify Partner
1 0 0

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

TanjaCodi
Shopify Partner
9 1 4

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.