Using the order extra fields
Order extra fields allow you to save some additional information to orders — buyers can add custom data at checkout and this information will appear in the orders details in Ecwid admin panel. It can be visible or hidden from customer.
Additional tools for working with order extra fields include two functions and an array of objects: getOrderExtraFieldValue("key"), getOrderExtraField("key"), order.extraFields.
Order extra fields structure:
${order.extraFields} | |
<#list order.extraFields as extraField> </#list> | Displays the list of order extra fields. |
${extraField.key} | Displays the extra field' key. |
${extraField.value} | Displays the extra field's value. |
${extraField.title} | Displays the extra field' title. Optional. |
${extraField.orderDisplaySection} | Displays the extra field's title. Optional. |
${extraField.type} | Displays the extra field's type. |
Here are some examples:
Show all order extra fields set to be visible in order details (title and orderDisplaySection is specified)
<#list order.extraFields as extraField> <#if extraField.title?has_content && extraField.orderDisplaySection?has_content> ${extraField.title}: ${extraField.value} </#if> </#list>
Print value of a specific order extra field
<#assign myExtraFieldValue = getOrderExtraFieldValue("askHowYouFoundUsApp")>
<#if myExtraFieldValue?has_content>
${myExtraFieldValue}
</#if>
Where "askHowYouFoundUsApp" is the key of your order extra field.
Print specific fields of a specific order extra field (remove fields you don't need to show)
<#assign myExtraField = getOrderExtraField("askHowYouFoundUsApp")>
${myExtraField.key}
${myExtraField.value}
${myExtraField.type}
${myExtraField.orderDisplaySection}
${myExtraField.title}
Where "askHowYouFoundUsApp" is the key of your order extra field.