'FTL attribute list filtering issue
I'm working on building my store in ecwid and doing some very basic modifications to the html based email confirmation templates that they provide. They use FTL for accessing a number of variables regarding product information - their main literature is here.
Goal
I would like to be able to use an "attribute" which is hidden from the product page but important for the email output - namely, providing a download link/code automatically on order confirmation. The language to access this is as follows:
<#list orderItem.attributes as attribute>
<p>${attribute.value} </p>
</#list>
where the <#list> item pulls in the attributes for the relevant product and ${attribute.value} reads out whatever hidden value I've stored in the relevant attribute.
Problem
However, the issue that I'm having is that the code above will list ALL attributes for a given product, and I have been unable thus far to filter the attributes to just the one I need (they have "UPC" and "Brand" attributes which are system generated and cannot be deleted). So, for the sample attributes / values below:
attribute_name | value
UPC | 83888924
Brand | Nike
download_code | www.download.com/code
The code listed would produce the following:
83888924
Nike
www.download.com/code
whereas I need code that will output only www.download.com/code
Tried so far
Based on the FTL in their (ecwid) literature and the FTL website, I have tried things like:
${attribute.value[2]} : yields the third character of each value, but still all three values
${attribute[2].value} : yields nothing and seemingly breaks all of my code
<#if ${attribute.attribute_name} == "download_code"><p>${attribute.value}</p></#if> : yields nothing and seemingly breaks all of my code
End
I assume I'm missing something very basic here; is anyone able to help?
Solution 1:[1]
Based on the documentation the name of the attribute is attribute.name instead of attribute.attribute_name.
The correct syntax is:
<#if attribute.name == 'download_code'><p>${attribute.value}</p></#if>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | obourgain |
