I have written following xslt code to get the order / order details and items contained in order.
<xsl:variable name="orders" select="CommerceLibrary:GetMemberOrderHistory('New order')"/> <xsl:if test="$customer/@nodeName!=''" > <xsl:for-each select="$orders/purchaseOrders/purchaseOrder"> Order Number: </span> <xsl:value-of select="@orderNumber"/> // following is written to get the line items of the current order <xsl:for-each select="$orders/purchaseOrders/purchaseOrder/lineItems/lineItem"> <xsl:value-of select="@productName"/> </xsl:for-each> </xsl:for-each> </xsl:if>
But on second foreach statment <xsl:for-each select="$orders/purchaseOrders/purchaseOrder/lineItems/lineItem">, i want to get line items for current order but it gives me products for all the orders. Please guide whats woring in the code / logic.
You shouldn't access to $orders from inside your first for-each. The latter already points to an purchaseOrder. Just take this and iterate through its lineItems. Your second for-each should read something like this: <xsl:for-each select="lineItems/lineItem"/>
get order items in xslt
Hi
I have written following xslt code to get the order / order details and items contained in order.
<xsl:variable name="orders" select="CommerceLibrary:GetMemberOrderHistory('New order')"/>
<xsl:if test="$customer/@nodeName!=''" >
<xsl:for-each select="$orders/purchaseOrders/purchaseOrder">
Order Number: </span> <xsl:value-of select="@orderNumber"/>
// following is written to get the line items of the current order
<xsl:for-each select="$orders/purchaseOrders/purchaseOrder/lineItems/lineItem">
<xsl:value-of select="@productName"/>
</xsl:for-each>
</xsl:for-each>
</xsl:if>
But on second foreach statment <xsl:for-each select="$orders/purchaseOrders/purchaseOrder/lineItems/lineItem">, i want to get line items for current order but it gives me products for all the orders. Please guide whats woring in the code / logic.
Nauman
You shouldn't access to $orders from inside your first for-each. The latter already points to an purchaseOrder. Just take this and iterate through its lineItems. Your second for-each should read something like this: <xsl:for-each select="lineItems/lineItem"/>
Best regards
Christian
Christian
Thanks for the tip, but the <xsl:for-each select="$orders/purchaseOrders/purchaseOrder[$position]/lineItems/lineItem"> did the job.
Nauman
is working on a reply...