Hi @AnupKM !
Welcome to the community)
Yes, you can place the product table inside the loop in the code you provided. The loop is used to iterate over the line items in the event.extra.line_items array. For each iteration of the loop, you can access the properties of the current item and use them to populate the product table.
Here's an example of how you might use this loop to generate a product table in an HTML email:
{% if event.extra.line_items %}
<table>
<thead>
<tr>
<th>Product Image</th>
<th>Product Name</th>
<th>Quantity</th>
<th>Price</th>
</tr>
</thead>
<tbody>
{% for item in event.extra.line_items %}
<tr>
<td><img src="{{ item.image_url }}" alt="{{ item.name }}"></td>
<td>{{ item.name }}</td>
<td>{{ item.quantity }}</td>
<td>{{ item.price | money }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No items in cart</p>
{% endif %}
This code will generate a table that displays the product image, name, quantity, and price for each item in the event.extra.line_items
array. If there are no items in the array, the code will display a message saying "No items in cart".
Hi @Irrra
So sorry, i’m newbie on this, can you please help a little more?
I see the variables are different in another source, if it’s like this then what will be the diffrent?
I am using it for Shopify, will this and your’s one make any difference or the same output or is this one wrong:
{% if event.extra.line_items %}
<table>
<thead>
<tr>
<th>Product Image</th>
<th>Product Name</th>
<th>Quantity</th>
<th>Price</th>
</tr>
</thead>
<tbody>
{% for item in event.extra.line_items %}
<tr>
<td><img src="{{ item.product.image.src }}" alt="{{ item.product.title }}"></td>
<td>{{ item.product.title }}</td>
<td>{{ item.quantity }}</td>
<td>{{ item.line_price }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No items in cart</p>
{% endif %}
Hi @AnupKM!
Most likely both codes will work, you can try and choose the best one for you