Solved

Shopping Cart Quantity Issue !! Help!

Posted on 2004-04-30
10
387 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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.…
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
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…

726 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