Question

How to show dynamic images of products in Order Confirmation Email

  • 26 December 2023
  • 2 replies
  • 197 views

Badge +3

Hi,

I’m setting up a custom HTML for an Order Confirmation email flow. Right now I’ve been able to pull all the products in a certain order but I’m having trouble showing the images of said products dynamically, for example I know I can pull specific images like so:

{{ event.extra.Items.0|lookup:'$extra'|lookup:'Images'|lookup:'0'|lookup:'URL'|default:'' }}

 

But what if I want to pull those images dynamically within the loop? The code above only pulls the first image in the product array (At least that’s my understanding of it).

 

Can someone take a look and let me know the right code to show images dinamically in the loop?

(see below the images repeating in both products)

 

 


2 replies

Userlevel 7
Badge +60

Hey@sperezclavier 

Thanks for reaching out for help with your order confirmation email.

You should be able to use the following as the image placeholder tag:
{% if item.product.variant.images.0.src %}{{item.product.variant.images.0.src}}{%else%}{{item.product.images.0.src|missing_product_image}}{%endif%}

Let me know if this works for you!

Badge +3

Hi Stephen!

Thanks for your reply, what I was actually looking for is the code syntax to be able to pull the product image for the first product in the confirmation email. As you can see in my example above i’m only able to pull the product when I specify the “.0.” part. Is there a way to code it in a way that it pulls the images depending on the product order?

For example you can see in my screenshot above that the product name, quantity and cost are all pulling correctly, i’m using these codes for those:

{{ item.Name|safe }}

{{ item.Quantity|floatformat:0 }}

{{ item.Price|floatformat:2 }}

 

I want to be able to do the same for the images. Hope this clarifies it.

Best,

Reply