Collections in Email Templates
- 13 Sep 2022
- 1 Minute to read
- Print
- DarkLight
- PDF
Collections in Email Templates
- Updated on 13 Sep 2022
- 1 Minute to read
- Print
- DarkLight
- PDF
Article summary
Did you find this summary helpful?
Thank you for your feedback
Required permissions
An employee must be assigned to the Shop with a Power User role or higher to create and edit templates on a Shop Owner level.
How to add merge field collection
To insert a collection of merge fields into a mail template:
- Open mail template for editing.
- Start the collection by inserting
RangeStart:
and follow it by the collection name. This will identify the starting point of the collection. - Use comment tags
<!--
-->
to comment the range start merge field and prevent it from rendering on the final document. - Proceed with inserting the collection body that could consist both of text and specific merge fields from the collection chosen. Format the merge fields, if required.
- To close the collection, insert the
RangeEnd:
and follow by the respective collection name. - Enclose the
RangeEnd:CollectionName
in a comment tags. - Proceed with editing the template as usual.
For example, a table with products ordered:
<table>
<tr>
<th>Product Code</th>
<th>Product Name</th>
<th>Quantity</th>
<th>Price(Inc)</th>
<th>Row Total($$Order.CurrencySymbol$$)</th>
</tr>
<!-- RangeStart:OrderRow-->
<tr>
<td>$$OrderRow.ProductCode$$</td>
<td>$$OrderRow.ProductName$$</td>
<td>$$OrderRow.ItemQuantity##,##.$$</td>
<td>$$OrderRow.ItemPriceIncVat###,##.00$$</td>
<td>$$OrderRow.RowTotalIncVat##,###.00$$</td>
</tr>
<!-- RangeEnd:OrderRow-->
</table>
Example of generated products list:
Nested field collections
Nest collections inside other collections to show only values that are related to the current value of the parent collection.
For example, the ProductRegistration collection is nested inside the OrderRow collection.
<table>
<tr>
<th>Product Code</th>
<th>Product Name</th>
<th>Product Registration</th>
<th>Quantity</th>
<th>Price(Inc)</th>
<th>Row Total($$Order.CurrencySymbol$$)</th>
</tr>
<!-- RangeStart:OrderRow-->
<tr>
<td>$$OrderRow.ProductCode$$</td>
<td>$$OrderRow.ProductName$$</td>
<!-- RangeStart:ProductRegistration-->
<td> $$ProductRegistration.SerialNumber$$</td>
<!-- RangeEnd:ProductRegistration-->
<td>$$OrderRow.ItemQuantity##,##.$$</td>
<td>$$OrderRow.ItemPriceIncVat###,##.00$$</td>
<td>$$OrderRow.RowTotalIncVat##,###.00$$</td>
</tr>
<!-- RangeEnd:OrderRow-->
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td><p style="text-align: right;"></p>$$Order.CurrencySymbol$$$$Order.TotalDue##,###.00$$</td>
</tr>
</table>