?
Solved

Shopping Cart Quantity Issue !! Help!

Posted on 2004-04-30
10
Medium Priority
?
390 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
7 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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 580 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ranking ecommerce websites is a vital process. You need to have a strong SEO (Search Engine Optimization) strategy. If you don’t have one, you are losing out on brand impressions, clicks and sales. Check this guide on how to improve website traffic …
In the below post we have mentioned the best hosting type for startups. Also, check out some of the superlative web hosting companies that are proposing affordable web hosting solutions to host your startup website.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
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…
Suggested Courses

850 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