A sample View Cart XSLT follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
<xsl:stylesheet 
	version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:msxml="urn:schemas-microsoft-com:xslt"
	xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:procure="urn:procure" 
	exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets procure ">


<xsl:output method="xml" omit-xml-declaration="yes"/>

<xsl:param name="currentPage"/>

<xsl:template match="/">
<xsl:variable name='temp' select='procure:ProcessCart()'/>
<xsl:variable name='cart' select='procure:GetCurrentCart()'/>
<xsl:variable name='products' select='$cart/products/product'/>
<form action="" method="post">
<table>
	<thead>
		<tr>
			<td>Product</td>
			<td>Price</td>
			<td>Quantity</td>
			<td>Total</td>
			<td></td>
		</tr>
	</thead>
	<tbody>
	<xsl:for-each select="$products">
		<xsl:call-template name='product'>
			<xsl:with-param name='cartProduct' select='.'/>
		</xsl:call-template>
	</xsl:for-each>

	</tbody>
	<tfoot>
		<tr>
			<td colspan="2">Subtotal</td>
			<td><xsl:value-of select='$cart/@itemCount'/></td>
			<td><xsl:value-of select='$cart/@subtotal'/></td>
		</tr>
		<tr>
			<td colspan='4'>
				<input type='Submit' name='{procure:GetUpdateAllButtonName()}' value='Update All'/>
				<input type='Submit' name='{procure:GetClearButtonName()}' value='Clear'/>
			</td>
		</tr>
	</tfoot>
	
</table>
</form>
</xsl:template>

<xsl:template name="product">
	<xsl:param name='cartProduct'/>
	<xsl:variable name='product' select='procure:GetProduct($cartProduct/@productId)'/>
	<tr>
		<td><xsl:value-of select='$product/name/text()'/></td>
		<td><xsl:value-of select='$cartProduct/@price'/></td>
		<td><input type='text' name='{procure:GetQuantityInputName($cartProduct/@productId)}' value='{$cartProduct/@quantity}'/></td>
		<td>
			<xsl:value-of select='$cartProduct/@total'/>
			<input type='hidden' name='{procure:GetProductIdInputName($cartProduct/@productId)}' value='{$cartProduct/@productId}' text='a'/>
			<input type='submit' name='{procure:GetUpdateButtonName($cartProduct/@productId)}' value='Update'/>
			<input type='submit' name='{procure:GetRemoveButtonName($cartProduct/@productId)}' value='Remove'/>

		</td>
	</tr>
</xsl:template>

</xsl:stylesheet>

Last edited Jan 18, 2010 at 3:19 PM by cyberknet, version 1

Comments

No comments yet.