Hi Team,
We have a requirement to list all product details in the email body shared in the ctx payload,
the payload is as below
<ctx>
<orderDetails>
<firstName>Shine</firstName>
<lastName>vv</lastName>
<pickUpDate>28 Aug 2023 </pickUpDate>
<pickUpStore>XXYY </pickUpStore>
<orderId>TESTORDERID001 </orderId>
<subTotal>22001.00 </subTotal>
<discount>5000.00 </discount>
<tax>1200.00 </tax>
<total>20000.00 </total>
<advanceId>ADVANCEID001 </advanceId>
<advanceAmountPaid>5000.00 </advanceAmountPaid>
</orderDetails>
<productDetails>
<product1>
<productName>product1 </productName>
<productPrice>18000.00 </productPrice>
</product1>
<product2>
<productName>product2 </productName>
<productPrice>18000.00 </productPrice>
</product2>
</productDetails>
</ctx>
The required output in the email body is as below :
Product 1
productName :
productImage :
productPrice :
Product 2
productName :
productImage :
productPrice :
Product 3
productName :
productImage :
productPrice :
.
.
.
etc
There can be n number of products and all of the products must be displayed in the email. Trying to loop through the xml code like below :
<% var ctx = XML(rtEvent.ctx); %>
<% for(var i=1;i <= ctx.productDetails.childNodes.length;i++){%>
<%=escapeXmlStr(ctx["product"+i+".productName"])%> <%=escapeXmlStr(ctx["product"+i+".productImageUrl"])%>
<% } %>
but i am not getting any out put,
Please help me on the same, Thanks in advance.
Thanks,
Shine v.v