Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ListFind(ArrayToList

Status
Not open for further replies.

coldfused

Technical User
Jan 27, 2001
2,442
US
Shopping Cart - Add Items

I want to check and see if first Session.Cart.ProductID exist. If no Session.Cart.ProductID exist then do not allow addtocart to take place. I want to force the members to pick a certain item first, before they are allowed to pick certain others. So the code below checks for the existing Session.Cart.ProductID if none exist redirect with an error message. Works fine for the first check.

User selects an item and because there is no ProductId Session yet they get errored out and asked to pick the right item first. That happened because Session.Cart.ProductID did not exixt. So now they go back and choose the right item, Session.Cart.ProductID is GT 0, so they should be able to add anything they want now.

For some reason after the first check, and the correct item has been added first (which means the session is now GT 0) it doesnt recognize Session.Cart.ProductID and should ignore the rest of the current if statement and move on to the cfelseif that follows.

Make sense?

Code:
<cfif ListFind(ArrayToList(Session.Cart.ProductID),FORM.ProductID) 
	EQ 0 AND (
	Form.ProductID EQ "FCSS-kgtt" 
	OR Form.ProductID EQ "FCSS-gfds" 
	OR Form.ProductID EQ "FCSS-erty"
	OR Form.ProductID EQ "FCSS-nbZc"
	OR Form.ProductID EQ "FCSS-iyew"
	OR Form.ProductID EQ "FCSS-mmbb"
	OR Form.ProductID EQ "FCSS-q3fe"
	OR Form.ProductID EQ "FCSS-bvcd")>
  <cflocation url="#cgi.path_info#?needtoaddconf=yes&type=#URL.type#" addtoken="no">

----------------------------------------
Florida Web Design
Orlando Web Hosting
Florida Coldfusion Hosting
 
Your if says
"if the current form value is not found in the array AND the form value = one of a bunch of strings then do a cflocation."
is that what you're trying to do?

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
For the first check yes. Then if any item is added to the cart after that initial check (Session.Cart.ProductID),FORM.ProductID) EQ 0 should no longer be true and it should by pass this snippet and move on to the next. Only thing is it does not bypass on the second go around. Works fine for the initial check.

----------------------------------------
Florida Web Design
Orlando Web Hosting
Florida Coldfusion Hosting
 
ok, but you're comparing it to a form field.

if the user pics a new part number that isn't in the array, it will eq 0 (true). if the second product you're adding is in that group of OR values (true) the whole cfif will be true and trigger the cflocation.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top