Solved

Shopping Cart Quantity Issue !! Help!

Posted on 2004-04-30
10
383 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

E-commerce is quite a gambling world, and you should never entrust your business to a lucky chance. In order to outrun your competitors in a race to attract as many customers as possible, you need to have a well thought-out strategy under your belt.…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
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…

813 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