ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old March 8th, 2005, 03:52 AM
perlnewbie23 perlnewbie23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 105 perlnewbie23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 sec
Reputation Power: 4
HELP: Displaying shopping cart information.

Hi, I'm just starting to learn Coldfusion and have a problem. I'm trying to display the details iof my shopping cart before it gets checkout but nothing gets displayed. Here is my code:
PHP Code:
<cfquery name"OrderProduct" datasource="shoes">
SELECT shoeIDmanufactorIDbrandnamesizecolortypeprice
FROM shoe WHERE shoeID
=#shoeID#
</cfquery>

<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<
html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
title>Untitled Document</title>
</
head>

<
body>
<
cfif IsDefined ("Session.cart")>
<
cfoutput query "OrderProduct">
<
cfset subtotal=0>
<
cfloop index="element" from="0" to="#ArrayLen(Session.cart.CartDescription)#">
<
div align="center">
<
table width="507" border="1" cellpadding="1">
  <
tr>
    <
td width="74">Manufactor ID</td>
    <
td width="37">Brand</td>
    <
td width="37">Name</td>
    <
td width="64">Size</td>
    <
td width="76">Color</td>
    <
td width="68">Type</td>
    <
td width="105">Price</td>
  </
tr>
  <
tr>
    <
td>#Session.cart.manufactorID[element]#</td>
    
<td>#Session.cart.brand[element]#</td>
    
<td>#Session.cart.name[element]#</td>
    
<td>#Session.cart.size[element]#</td>
    
<td>#Session.cart.color[element]#</td>
    
<td>#Session.cart.type[element]#</td>
    
<td>#Session.cart.price[element]#</td>
  
</tr>
  <
tr>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
  </
tr>
</
cfloop>
</
CFOUTPUT>
  </
table>
</
cfif>
  <
p>&nbsp;</p>
</
div>
</
body>
</
html


Please help and bear with me. Thanks!

Reply With Quote
  #2  
Old March 8th, 2005, 08:45 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
I suspect that the structure of the cart variable is not what you think it is. Use <cfdump var="#session.cart#"> to confirm what is in the cart, and output the variables accordingly.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old March 8th, 2005, 05:40 PM
perlnewbie23 perlnewbie23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 105 perlnewbie23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 sec
Reputation Power: 4
Quote:
Originally Posted by kiteless
I suspect that the structure of the cart variable is not what you think it is. Use <cfdump var="#session.cart#"> to confirm what is in the cart, and output the variables accordingly.


Hi, I've tried using <cfdump var="#session.cart#"> but i'm still having the same problem. SOmehow i'm suspecting something is wrong with the cfif statement. Here is how I used <cfdump var="#session.cart#">:

PHP Code:
<cfquery name"OrderProduct" datasource="shoes">
SELECT shoeIDmanufactorIDbrandnamesizecolortypeprice
FROM shoe WHERE shoeID
=#shoeID#
</cfquery>

<!
DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<
html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
title>Untitled Document</title>
</
head>

<
body>

<
cfif IsDefined ("session.cart")>
<
cfdump var="#session.cart#">
<
cfset subtotal=0>
<
cfloop index="element" from="1" to="#ArrayLen(session.cart)#">
<
cfoutput query "OrderProduct">

<
div align="center">
<
table width="507" border="1" cellpadding="1">
  <
tr>
    <
td width="74">Manufactor ID</td>
    <
td width="37">Brand</td>
    <
td width="37">Name</td>
    <
td width="64">Size</td>
    <
td width="76">Color</td>
    <
td width="68">Type</td>
    <
td width="105">Price</td>
  </
tr>
  <
tr>
    <
td>#session.cart[element][OrderProduct.manufactorID]#</td>
    
<td>#session.cart.brand[element]#</td>
    
<td>#session.cart.name[element]#</td>
    
<td>#session.cart.size[element]#</td>
    
<td>#session.cart.color[element]#</td>
    
<td>#session.cart.type[element]#</td>
    
<td>#session.cart.price[element]#</td>
  
</tr>
  <
tr>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
    <
td>&nbsp;</td>
  </
tr>
  </
CFOUTPUT>
</
cfloop
</
cfif>
</
table>
  <
p>&nbsp;</p>
</
div>
</
body>
</
html

Reply With Quote
  #4  
Old March 8th, 2005, 07:11 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
No that tooks fine. What does the cfdump show you? Also, alter the inner cfouput so that it isn't outputting a query.

Make this:

<cfoutput query = "OrderProduct">

into this:

<cfoutput>

You're not outputting a query, you're looping over an array.

Reply With Quote
  #5  
Old March 8th, 2005, 08:43 PM
perlnewbie23 perlnewbie23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 105 perlnewbie23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 sec
Reputation Power: 4
Quote:
Originally Posted by kiteless
No that tooks fine. What does the cfdump show you? Also, alter the inner cfouput so that it isn't outputting a query.

Make this:

<cfoutput query = "OrderProduct">

into this:

<cfoutput>

You're not outputting a query, you're looping over an array.


Sorry I tried doing what you said, but still nothing is shown on the screen. It's just blank. Any more ideas what could be wrong?

Reply With Quote
  #6  
Old March 8th, 2005, 09:52 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Are you saying the <cfdump> is also blank? If that's the case then the problem is that there is nothing in the cart, or the structure of cart has errors.

I'd think about starting over if it's the cart. I have a whole article on building a shopping cart at builder.com. I should note that there are two errors in the code presented.

The line:
<cfparam name="session.cart" default="arrayNew()">
shoulde be:
<cfparam name="session.cart" default="#arrayNew()#">

and the line:
<cfset session.cart = arrayAppend( session.cart, structNew() )>
should be
<cfset arrayAppend( session.cart, structNew() )>

Last edited by kiteless : March 8th, 2005 at 10:04 PM.

Reply With Quote
  #7  
Old March 8th, 2005, 10:18 PM
perlnewbie23 perlnewbie23 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 105 perlnewbie23 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 41 sec
Reputation Power: 4
Quote:
Originally Posted by kiteless
Are you saying the <cfdump> is also blank? If that's the case then the problem is that there is nothing in the cart, or the structure of cart has errors.

I'd think about starting over if it's the cart. I have a whole article on building a shopping cart at builder.com. I should note that there are two errors in the code presented.

The line:
<cfparam name="session.cart" default="arrayNew()">
shoulde be:
<cfparam name="session.cart" default="#arrayNew()#">

and the line:
<cfset session.cart = arrayAppend( session.cart, structNew() )>
should be
<cfset arrayAppend( session.cart, structNew() )>



Ok I have a site that has a form with a button that says Add To Cart and was wondering if this i'm doing the site correctly. Here is the site that has the 'Add to cart' button before i press the add to cart button.

PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<
html>
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
title>Air Jordan 1</title>
</
head>

<
body>

<
cfquery name "aj1shoelist" datasource "shoes">
SELECT shoeIDimageURLnamebranddetailspricesizecolor 
from Shoe WHERE name 
'Air Jordan 1'
</cfquery>
<
cfoutput query="aj1shoelist">
<
form action ="viewcart2.cfm?ShoeID=#shoeID#" method="post">
<
p><img src "/soleshop/AirJordan1/aj1black_blue.jpg" alt="Image" width="150" height="100"/> </p>
<
table border="1" width="801" height="170"
    <
tr>
    <
td width="90" height="21"><strong>NAME: </strong></td>
    <
td width="699">#name#</td>
    
</tr>
    <
tr>
    <
td height="21"><strong>BRAND: </strong></td>
    <
td>#brand#</td>
    
</tr>
    <
tr>
    <
td height="21"><strong>DETAILS: </strong></td>
    <
td>#details#</br></td>
    
</tr>
    <
tr>
    <
td height="21"><strong>COLOR: </strong></td>
    <
td>#color#</br></td>
    
</tr>
    <
tr>
    <
td height="21"><strong>PRICE:</strong></td>
    <
td>#price#</td>
    
</tr>
    <
tr>
      <
td height="26"><strong>SIZE:</strong></td>
      <
td><SELECT NAME="Size">
        <
OPTION>Select a size</OPTION>
        <
OPTION VALUE="#size#">#size#</OPTION>
      
</SELECT></td>
    </
tr>
    <
tr>
    <
td height="21">&nbsp;</td>
    <
td>&nbsp;</td>
    </
tr>
</
table>
</
cfoutput>

<
p>
  <
input name="Add" type="submit" id="Add" value="Add to cart">
</
p>
</
form>
<
p><a href="Welcome.htm">Home</a>
</
p>

</
body>
</
html

Reply With Quote
  #8  
Old March 9th, 2005, 08:19 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
That seems all right to me. But you seem to be missing the point: you can submit the form and then on the action page use <cfdump var="#form#"> to dump out what's the in the form scope and decide for yourself if the right values are there.

If you're still confused I think you might just be moving too fast. You can always back up a bit, start with a simple form and a simple cart, and then slowly add things in. You don't have to go from nothing all the way to a complicated form a cart right away.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > HELP: Displaying shopping cart information.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump