I am trying to write a sidebar that lists all the contents of a shopping cart, adds the items together, offers a subtotal and then enter a coupon to subtract an amount giving the final total. The code that I have listed below works to an extent..here is an example how it would display:
Series Title 1
2 A tickets = $480
Series Title 2
2 B Tickets =$230
Subtotal:$480
$230
I would like to be able to add the two subtotal numbers together and also add an input field that would allow for a coupon code whose value could come from the DB. Then finally total it all up.
-------------------------------------------
Code
------------------------------------------
<cfquery name="getMerch" datasource="#APPLICATION.dataSource#"
cachedWithin="#createTimeSpan(0,1,0,0)#">
SELECT
m.MerchName
,m.MerchDescription
,m.MerchPrice
,m.ImageNameSmall
,f.SeriesID
,f.SeriesTitle
FROM
merchandise m INNER JOIN films f
ON m.SeriesID = f.SeriesID
WHERE
m.MerchID = #ATTRIBUTES.merchID#
</cfquery>
<!--- Get current cart contents, as a query object --->
<cfset getCart = SESSION.myShoppingCart.List()>
<!---Your Order--->
<cfloop query="getCart">
<!--- Now display information of what is in the cart --->
<cfoutput>
<table cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">
<span style="color:##ffb505;">#getMerch.SeriesTitle#</span>
</td>
</tr>
<tr>
<td style="padding:0 5px 0 0">#getCart.Quantity#</td>
<td style="padding:0 5px 0 0">
<p>#getMerch.MerchName#</p>
</td>
<td class="price">
<p>#lsCurrencyFormat(getMerch.MerchPrice * getCart.Quantity)#</p>
</td>
</tr>
</table>
</cfoutput>
</cfloop>
<!---Display the subtotal of the cart--->
<cfloop query="getCart">
<cfoutput>
<table cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">
<p>#lsCurrencyFormat(getMerch.MerchPrice * getCart.Quantity)#</p>
</td>
</tr>
</table>
</cfoutput>
</cfloop>
Series Title 1
2 A tickets = $480
Series Title 2
2 B Tickets =$230
Subtotal:$480
$230
I would like to be able to add the two subtotal numbers together and also add an input field that would allow for a coupon code whose value could come from the DB. Then finally total it all up.
-------------------------------------------
Code
------------------------------------------
<cfquery name="getMerch" datasource="#APPLICATION.dataSource#"
cachedWithin="#createTimeSpan(0,1,0,0)#">
SELECT
m.MerchName
,m.MerchDescription
,m.MerchPrice
,m.ImageNameSmall
,f.SeriesID
,f.SeriesTitle
FROM
merchandise m INNER JOIN films f
ON m.SeriesID = f.SeriesID
WHERE
m.MerchID = #ATTRIBUTES.merchID#
</cfquery>
<!--- Get current cart contents, as a query object --->
<cfset getCart = SESSION.myShoppingCart.List()>
<!---Your Order--->
<cfloop query="getCart">
<!--- Now display information of what is in the cart --->
<cfoutput>
<table cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">
<span style="color:##ffb505;">#getMerch.SeriesTitle#</span>
</td>
</tr>
<tr>
<td style="padding:0 5px 0 0">#getCart.Quantity#</td>
<td style="padding:0 5px 0 0">
<p>#getMerch.MerchName#</p>
</td>
<td class="price">
<p>#lsCurrencyFormat(getMerch.MerchPrice * getCart.Quantity)#</p>
</td>
</tr>
</table>
</cfoutput>
</cfloop>
<!---Display the subtotal of the cart--->
<cfloop query="getCart">
<cfoutput>
<table cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">
<p>#lsCurrencyFormat(getMerch.MerchPrice * getCart.Quantity)#</p>
</td>
</tr>
</table>
</cfoutput>
</cfloop>