Solved

Shopping Cart Quantity Issue !! Help!

Posted on 2004-04-30
10
379 Views
Last Modified: 2013-12-24
I'm having an issue with my shopping cart.  When I set up my quantity it for some reason is outputting the numbers incorrectly as if it's not in the array.  By this I mean :
Quantity     in Stock     SKU
[1,1,33]     Yes            8306    
[1,5]         Yes             5564  
[1,5]         No               3482
Everytime I add a new product and update the quantity it adds it to the current Variable in my URL for instance ?pID=8306.. If I change the quantity of another product in my shopping cart, because 8306 is selected in my URL it will add a delim like 1,2 or something of that nature.  Sorry If i'm somewhat confusing i'm a novice developer.  Here is a snippet of my code=

<cfif ListFind(ArrayToList(Session.vCart.ProdID),#url.pID#) NEQ 0>
<cfset ThisItem = ListFind(ArrayToList(Session.vCart.ProdID), #url.pID#)>
 <cflock timeout="2" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
<cfset Session.vCart.Qty[ThisItem]=FORM.Qty>
</cflock>              
            
 <cfif isDefined('form.updatesubmit') IS "TRUE" AND ListFind(ArrayToList(Session.vCart.Qty),#form.qty#) NEQ 0>
<cfset ThisItem = ListFind(ArrayToList(Session.vCart.Qty), #form.qty#)>
<cflock timeout="2" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
<cfset Session.vCart.Qty[ThisItem] = Session.vCart.Qty[ThisItem]>
<cfset Session.vCart.Qty[ThisItem] = FORM.qty>
</cflock>
</cfif>
<cfelse>
<cfset ThisItem=ArrayLen(Session.vCart.ProdID) +1 >
<!--- === [ Add to cart ] === // --->
<cflock timeout="5" throwontimeout="No" type="EXCLUSIVE" scope="SESSION">
<cfset Session.vCart.ProdID[ThisItem]=#url.pID#>
<cfset Session.vCart.Qty[ThisItem]=FORM.Qty>
</cflock>
</cfif>

I have gotten it so the products input correctly, however the quantities do not work.  Does anyone have any suggestions at all?  I wasn't sure if i have to set up some sort of array or what, but any help you can provide will GREATLY help me out! Thanks!

Dave
0
Comment
Question by:ctdigital
  • 2
  • 2
  • 2
  • +1
10 Comments
 
LVL 3

Expert Comment

by:mvwmail
ID: 10963625
You have one of your FORM.qty in #'s whilst all the others are not? Not had enough coffee to actually work through the code
0
 
LVL 3

Expert Comment

by:mvwmail
ID: 10963643
<cfset Session.vCart.Qty[ThisItem]=FORM.Qty>

should maybe read

<cfset Session.vCart.Qty[ThisItem]=#FORM.Qty#>
0
 
LVL 1

Author Comment

by:ctdigital
ID: 10976903
That was accidental, but irregardless has no different outcome whichever way I do it.  I still have not figured out the problem for this, and sorry for the delayed response over the weekend.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 2

Expert Comment

by:netuser1976
ID: 10981551
I think you have some mismatched <cfif> <cfelse> </cfif> - atleast in what you've posted..

My other suspicion is this line. I dont understand why you need this ...

<cfset Session.vCart.Qty[ThisItem] = Session.vCart.Qty[ThisItem]>
0
 
LVL 2

Expert Comment

by:netuser1976
ID: 10981558
Oops.. Sorry I should take back what I posted about mismatched cfif/cfelse
0
 
LVL 1

Author Comment

by:ctdigital
ID: 10985879
<cfset Session.vCart.Qty[ThisItem] = Session.vCart.Qty[ThisItem]>

That statement still shouldnt affect it, and am currently still working on this..
0
 
LVL 1

Accepted Solution

by:
poorgod earned 145 total points
ID: 11009453
ok, this may be wrong, but i'll give it a shot.
are the form fields all named Qty?
i mean, if the form page has more than one Qty field in it, like,
<input type="text" name="Qty" value="1">
<input type="text" name="Qty" value="5">
<input type="text" name="Qty" value="10">
then in the next page, form.qty will give you the value "1,5,10"
instead of that you might use something like
<input type="text" name="Qty8306" value="1">
<input type="text" name="Qty5564" value="5">
<input type="text" name="Qty3482" value="10">
and then in the action page,
<cfset Session.vCart.Qty[ThisItem]=evaluate("FORM.Qty#url.pID#")>

Hope the helps
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now