Custom Field in Order Confirmation Email

Ben Bricker asked on May 12, 2016 17:36

I'm trying to get a field from a custom product type to show up in the Order Confirmation email. I'm not sure how to pull in the field from the custom page type. I'm using the default transformation for the products in the email template, and it looks something like this:


    <td style="text-align: left">{%(IsProductOption) ? "&nbsp;&nbsp;-&nbsp;" : ""%}{%Localize(SKUName)%}
    {%(CartItemText != "") ? (" '" + CartItemText + "'") : ""|(encode)%}
    <td>Units: {%Units%}</td>
    {% (ShoppingCart.IsDiscountApplied) ? ("<td>" + UnitTotalDiscount.Format("{0:F}") + "</td>") : "" #%}
    <td>Total Tax: {%TotalTax.Format("{0:F}")#%}</td>
    <td>Total Price: {%TotalPrice.Format(Currency.CurrencyFormatString)#%}</td>

Is there a way to pull in the custom page type fields since the page type is linked to the SKU? Or maybe through the CurrentDocument.NodeAliasPath macro? The page type has a table name of HFA_Product, and the field I'm trying to get from it is Description.


Recent Answers

Trevor Fayas answered on May 12, 2016 22:14

If you have the NodeAliasPath, you can use the macro

{% Documents.WithAllData["TheNodeAliasPath"].GetValue("MyField") %}

Try that!

ALso you can use the System -> Macros -> Console to test your macros out!

0 votesVote for this answer Mark as a Correct answer

Ben Bricker answered on May 13, 2016 19:52

Unfortunately, I don't seem to have access to the NodeAliasPath either. What I'm trying to do is loop through the OrderItems and matching them up with the page type that I have the custom field in. I think the macro needs to look something like this:

{% for(i = 0; i < Order.OrderItems.Count; i++) {
        for(j = 0; j < Documents["/HFA-Products"].Children.Count; j++) {
            if(Contains(Order.OrderItems[i].OrderItemSKU.ToString(), Documents["/HFA-Products"].Children[j].SKU.DisplayName.ToString()) {
    } %}

Iterating through the Documents["/HFA-Products"].Children isn't working though. It's like it isn't getting the count correct and then it just doesn't go through that loop. I know that Documents["/HFA-Products"].Children.Count is equal to 64 though, so it's not like I'm inputting a value of 0.

Any ideas why I can't iterate through the children like this?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.