Gift card email - png changing with amount

Topic summary

A user wants to display different gift card images in email notifications based on the purchase amount—Oak for amounts ≥1000 kr, Brass for ≥2000 kr, and Marble for ≥4000 kr.

Initial Solution Attempt:

  • Another user provided code using customer.total_spent conditions in the gift_card.liquid template file
  • This approach checks customer spending history rather than the specific gift card value

Implementation Issues:

  • The original poster reports syntax errors (red highlighting) when implementing the code
  • Subsequent attempts show no error messages but fail functionally:
    • Gift card emails not arriving with codes
    • Wrong images displaying in test emails

Current Status:

  • The discussion remains unresolved
  • The core problem appears to be using gift_card.initial_value (the actual gift card amount) versus customer.total_spent (customer’s historical spending)
  • The most recent code attempt includes conditional logic for three tiers but functionality is still broken
  • No working solution has been confirmed
Summarized with AI on November 5. AI used: claude-sonnet-4-5-20250929.

Hey!

I was wondering if it would be possible to set up three different pictures for the email recipient, depending on the amount the customer purchases.

We have three types of gift cards: Oak, Brass, and Marble. I would like the digital gift card (in PNG format) to be sent with the corresponding name on it.

Hi @ArchDK ,

Please go to Actions > Edit code > templates > gift_card.liquid file and change code here:

Code:

{%- if customer.total_spent > 10000 and customer.total_spent <= 20000 -%}
          Image 1
        {%- elsif customer.total_spent > 20000 and customer.total_spent <= 30000 -%}
          Image 2
        {%- elsif customer.total_spent > 30000 -%}
          Image 3
        {%- elsif settings.logo != blank -%}
          {%- assign logo_alt = settings.logo.alt | default: shop.name | escape -%}
          {{ settings.logo | image_url: width: 570 | image_tag: class: 'gift-card__image', alt: logo_alt }}
        {%- else %}
          
        {%- endif %}

You can also change the conditions for it yourself.

I hope it helps!

Hi @ArchDK ,

If you have any questions, you can contact me directly.

Nice to meet you :blush:

Hi, this isn’t working for me unfortunately. These two is red when writing them:

{% if gift_card > 1000 and customer.total_spent <= 2000 %}
Image 1
{% elsif total_spent > 20000 and customer.total_spent <= 30000 %}

Hi! It is still messing me up.

{% if gift_card > 1000 and customer.total_spent <= 2000 %}

alt=“Image 1” width=“160” height=“160”>
{% elsif totalspent > 2000 and customer.total_spent <= 3000 %}

The red part is showing that it isnt working in the code

[image: Screenshot 2024-10-01 at 17.49.21.png]

Hi @ArchDK ,

Please send me a screenshot of the error message, I will check it again

Hi again I tried this one, which isnt showing any mistakes, but 1) the email with the gift card isn’t arriving with the code and its not showing the right gift card in the trial.

{% if gift_card.recipient %}
{% if gift_card.recipient.nickname != blank %}
{% assign recipient_name = gift_card.recipient.nickname %}
{% elsif gift_card.recipient.name != blank %}
{% assign recipient_name = gift_card.recipient.name %}
{% else %}
{% assign recipient_name = gift_card.recipient.email %}
{% endif %}
{% capture email_title %}
{% if gift_card.send_on != blank %}
Here’s your gift card that will be sent to {{ recipient_name }} on {{ gift_card.send_on | date: ‘%B %e, %Y’ }}.
{% else %}
Here’s your gift card that was sent to {{ recipient_name }}.
{% endif %}
{% endcapture %}
{% endif %}

{{ email_title }} .button__cell { background: {{ shop.email_accent_color }}; } a, a:hover, a:active, a:visited { color: {{ shop.email_accent_color }}; }
 
 

{% if shop.email_logo_url %}

{{ shop.name }}
{% endif %}
{{ email_title }}

{% if gift_card.recipient and gift_card.message != blank %}

"{{ gift_card.message }}"
{% endif %} {% if gift_card.expires_on %} {% endif %}
{{ gift_card.initial_value | money_with_currency }}
Expires {{ gift_card.expires_on | date: '%B %e, %Y' }}
{% if gift_card.initial_value >= 4000 %} Special image for 4000kr+ {% elsif gift_card.initial_value >= 2000 %} Special image for 2000kr+ {% elsif gift_card.initial_value >= 1000 %} Special image for 1000kr+ {% else %} Gift card image {% endif %}
{{ shop.name }}
Use the gift card code online
{{ gift_card.code | format_code }}
Visit online store
View gift card balance

{% if gift_card.pass_url %}

Add to Apple Wallet
{% endif %}

If you have any questions, reply to this email or contact us at {{ shop.email }}