The following code works fine, using the GetXML method to get the XPathNodeIterator, the bodyText variable is populated with the details for each order line:
XPathNodeIterator orders = TeaCommerce.Library.GetFinalizedOrdersXml().Current.Select("order"); TeaCommerce.Data.Order order = TeaCommerce.Razor.TeaCommerce.GetOrder(Convert.ToInt32(orders.Current.GetAttribute("id", ""))); var subscriptions = from ol in order.OrderLines select ol;
foreach (OrderLine subscriptionOrderLine in subscriptions) { int orderUmbracoLanguageID = Convert.ToInt32(orders.Current.GetAttribute("umbracoLanguageId", ""));
while (orderLines.MoveNext()) { Dictionary<string, XPathNodeIterator> parameters = new Dictionary<string, XPathNodeIterator>(); parameters.Add("orderLine", subscriptionOrderLine.GetXml()); string bodyText = XSLTHelper.InvokeXSLT("subscription_reminder_email.xslt", null, orderUmbracoLanguageID, parameters, false);
<code to send email ...> }
This code is a little more efficient as it is not calling GetOrder however it does not work. The bodyText variable gets set but is missing the order line property values for all but one order line.
int orderUmbracoLanguageID = Convert.ToInt32(orders.Current.GetAttribute("umbracoLanguageId", "")); XPathNodeIterator orderLines = orders.Current.Select("orderLine"); while (orderLines.MoveNext()) { Dictionary<string, XPathNodeIterator> parameters = new Dictionary<string, XPathNodeIterator>(); parameters.Add("orderLine", orderLines); string bodyText = XSLTHelper.InvokeXSLT("subscription_reminder_email.xslt", null, orderUmbracoLanguageID, parameters, false);
<code to send email ...> }
It's weird to me...what am I doing wrong? Is there a bug in XSLTHelper.InvokeXSLT?
If it was me I would run it locally and debug the code. You will be able to see if two orderlines is returned from you select, or if some mad pixie is tampering with your code!
XSLTHelper.InvokeXSLT - What am I doing wrong?
I have some code to run through a list of order lines and send emails using the following XSLT file:
The following code works fine, using the GetXML method to get the XPathNodeIterator, the bodyText variable is
populated with the details for each order line:
This code is a little more efficient as it is not calling GetOrder however it does not work.
The bodyText variable gets set but is missing the order line property values for all but one order line.
It's weird to me...what am I doing wrong? Is there a bug in XSLTHelper.InvokeXSLT?
Regards,
Matt
Hi Matt,
Have you tried <xsl:copy-of select="$orderLine" /> to see what is being added to that parameter?
How is it failing?
/Rune
Good idea Rune,
There's only one order with two orderlines.
The value of <xsl:copy-of select="$orderLine" /> is empty for the 2nd orderline works for the first.
Not sure why though.
Pretty weird stuff.
If it was me I would run it locally and debug the code. You will be able to see if two orderlines is returned from you select, or if some mad pixie is tampering with your code!
/Rune
is working on a reply...