Display OrderItemCustomData in Invoice

Payal gupta asked on May 6, 2020 11:25

Hi Team,

I am working on Kentico 12 SP (MVC). I need show OrderItemCustomData in invoice template using transformation.

How can I display it?

Recent Answers


Brian McKeiver answered on May 6, 2020 16:08 (last edited on May 6, 2020 16:11)

I think it is simply {% Order.OrderItems[0].OrderItemCustomData.NameofYourField %}

0 votesVote for this answer Mark as a Correct answer

Payal gupta answered on May 7, 2020 09:58

Hi Brian,

Thank you for your response.

I am having XML data in OrderItemCustomData column under Com_OrderItem table like:

<CustomData xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Receiver>
<RecipientName>Test Name</RecipientName>
<RecipientEmail>Test Email</RecipientEmail>
<Message>Test</Message>
</Receiver>
</CustomData>

So I want to display this data in order invoice template in tabular format.

What are the way to display above data by applying transformation using Macros or any other way? please suggest.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on May 7, 2020 18:35

Why are you saving your data at the item level? same data is duplicated for each item.

<table>
{%
    foreach (item in Order.OrderItems)
    { "<tr><td>item.OrderItemCustomData.RecipientName</td>" +            
      "<td>item.OrderItemCustomData.RecipientEmail</td>" +
      "<td>item.OrderItemCustomData.Message</td></tr>"
    }
%}
</table>
0 votesVote for this answer Mark as a Correct answer

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