Skip to main content
Participating Frequently
January 20, 2008
Question

Possible Noob question involving column totals

  • January 20, 2008
  • 2 replies
  • 336 views
I am running cf8 and ms sql 05. I consider myself an "advanced" beginner at coldfusion but getting better.

I tried searches on this forum & google but the solutions i found didnt work well for me.

I have a shopping cart that i wrote and i am unable to add up the totals for all products before it is sent to the database. i wanted the price totals for all products selected to be displayed but, alas i have been ripping out my hair on this as i cant get it to work. i know there is a real simple solution to this.

thanks in advance.

<cfif isdefined("url.action")>
<cfif url.action is "delete">
<cfset session.cart.removeitem(url.position)>
</cfif>
</cfif>
<cfset arcart = session.cart.getCart()>

Your Delivery Order

<td> Product</div></td>
<td><div align="center">Quantity</div></td>
<td><div align="center">Price</div></td>
<td> </td>

<cfoutput>
<cfloop from="1" to="#arraylen(arCart)#" index="counter">
<td>#arCart[counter].sheds.getsheds()#</td>
<td>#arCart[counter].quantity#</td>
<td>#dollarformat(arCart[counter].sheds.getprice())#</td>
<td><a href="cart.cfm?action=delete&position=#counter#">Delete</a></td>
</cfloop>
</cfoutput>
    This topic has been closed for replies.

    2 replies

    January 21, 2008
    I'd also suggest pulling the code at top like the attached code. No need to have nested if statements. Also, remember that trim is your friend.
    Inspiring
    January 21, 2008
    With the code you have now, right before your loop, set some variable to 0. Then in your loop, increment that variable by the price of that item multiplied by the quantity.