Additional images in order confirmation email

Highlighted
New Member
5 0 0

Hi team,

I've had a look on the forums and knowledgebase but could only find one real line of code about getting images to display in the order confirmation e-mail, but I need to display ALL that are shown for each line item. The below code is working, but only shows the default image.

<img src="{{ line | img_url: 'small' }}">

 

Can someone please suggest if there is an alternate for loop or way to call the other images?

Thank you in advance!

Paul.

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
60 0 13

Hey Paul,

Trey here from Shopify!

We can make some slight tweaks to the order confirmation email, specifically the part where the product image is being pulled, so that all of the product images are being pulled in instead.

In the Order Confirmation template, you will see the following section:

          {% if line.image %}
            <img src="{{ line | img_url: 'compact_cropped' }}" align="left" width="60" height="60" class="order-list__product-image"/>
          {% endif %}

We'll want to tweak this a bit and also add in a "for loop" so that we can display all of the product images into the email, you would end up with this:

          {% if line.image %}
          {% for image in line.product.images %} <!-- This line is added here -->
            <img src="{{ image | img_url: 'compact_cropped' }}" align="left" width="60" height="60" class="order-list__product-image"/> <!-- change "line | img_url:" to "image | img_url:" -->
          {% endfor %}
          {% endif %}

Hope that helps :)

 

Trey S
support@shopify.com

0 Likes
New Member
5 0 0

Hi Trey,

Thanks for the reply! My apologies, it was actually for the 'new order' notification, so I applied a similar code there and it worked well.

Here's what I wrote it as:

{% for line in line_items %}
{% for image in line.product.images %}
<img src="{{ image | img_url: 'small' }}">
{% endfor %}
{% endfor %}

Thanks again for your help.

Paul.

0 Likes
Highlighted
New Member
1 0 0

I want to include an image that is on my computer in the confirmation email. Can somebody help me?

0 Likes
Highlighted
Tourist
13 0 2

Did you figure this out? I am trying to do this.

0 Likes