[XSLT] Summing calculated values
Posted: Sat Nov 03, 2007 11:26 am
Hi,
Say I have this order/orderline/article structure in my application.
Each orderline:
The price is fetched from the article, all an all in a pretty BLOATED function I've tried to add up the calculated values for each order line:
This nicelt prints the value for each of the orderlines in an order, but how do I go about summing these values, I'm totally lost here. Any help is appreciated![/code]
Say I have this order/orderline/article structure in my application.
Each orderline:
Code: Select all
<orderline articleidref="article0003">
<quan>1</quan>
</orderline>
Code: Select all
<xsl:template name="total">
<xsl:param name="orderid_ref">0</xsl:param>
<xsl:variable name="tmp_subprice">
<!-- loop throuch all orderlines -->
<xsl:for-each select="/webshop/orders/order[@orderid=$orderid_ref]/orderregels/orderregel" >
<!-- remember quantity of current orderline -->
<xsl:variable name="tmp_artikelaantal" select="aantal" />
<!-- remember articleid from current line -->
<xsl:variable name="tmp_artikelid" select="@artikelidref" />
<!-- remember price from current article -->
<xsl:variable name="tmp_artikelprijs" select="number(translate(substring(/webshop/artikelen/artikel[@artikelid=$tmp_artikelid]/prijs, 3), ',', '.'))" />
<!-- calculate value of single orderline -->
<xsl:value-of select="$tmp_artikelaantal * $tmp_artikelprijs" />
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$tmp_subprice" />
</xsl:template>