Post-purchase or abandonned cart loop
Create a loop to display all products from the cart or the order with the information you wish (price, image, name...).
Example using Message Builder:

Syntax when using Liquid directly
{% for orderline in order.orderlines %}
Product : {{orderline.product.name}}
Product : {{orderline.product.external_id}}
Quantity : {{orderline.quantity}}
{% endfor %}
Warning: these loops are based on order lines, so you should not use product variable but orderline one, meaning {{orderline.product.name}}
and not {{product.name}}
.
NB: the variable to place behind the image to display dynamicaly the image of each product is: {{orderline.product.img_url}}
How to modify the order of the loop
You can use the "sort" filter like this to modify the order of any loop like this:
{% for orderline in order.orderlines | sort: "product.price" %}
You can choose any variable to sort the loop, examples:
{% for orderline in order.orderlines | sort: "total_price" %}
{% for orderline in order.orderlines | sort: "quantity" %}
{% for orderline in order.orderlines | sort: "product.name" %}
By default this will sort in descending order, if you want to sort in ascending order you can use the filter reverse like this:
{% for orderline in order.orderlines | sort: "product.price" | reverse %}
Updated 17 days ago