Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    mat
    mat is offline
    Regular Coder
    Join Date
    Jul 2002
    Posts
    199
    Thanks
    0
    Thanked 0 Times in 0 Posts

    pseudo add to cart with coldfusion

    On a result page i have listing the matching 'albums' it basically outputs a few things for each result (each matching album)

    -Artist
    -Album
    -Price
    -link to detail page
    -add to cart link


    this is a fake little project just for learning and the add to cart button does not yet do anything but i would like it to.

    How can i make it so that when that 'add to cart' link is clicked a session / cookie is set containing that particular albumname or albumid.

    Then later after you when you go to the fake checkout page the albums you previously 'added to cart' are listed.




    It is after all just fake and for playing with, i figure there is a simple way to do it right?

    on the checkout page all i have to do is something like:

    SELECT albumName artistName etc
    FROM tables
    WHERE albumID = '#session.albumid#' ?


    the question here is wether i use a session (dont know much about it) and how to get it to set the session when i click add to cart?

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i'm not sure i completely undersand your problem.

    i think it comes down to this : you want to store some data (an ID for the selected albums) somewhere, without writing it to a database + you want to retrieve the ID and use them as selectioncriteria to build the checkoutpage.

    How to do it depends on your app, the used language, servercapacity, etc.

    I use a lot of ASP lately, and I would store the ID's in session-variables.

    How ?
    - create/modify your global.asa (each time a user starts the application, a session for this user is created and space is reserved for the session-variables. )
    - create/modify your session_on start sub like this
    Sub Session_OnStart

    session("albumID")=0

    -when an album is selected, post the form to an ASP page where you store the ID in the sessionvariables like this

    session("albumID")=request.form("albumID")

    - to retrieve the ifno and use it in a selectquery:

    sql="SELECT albumName artistName etc FROM tables WHERE albumID = anID"
    sql=replace(sql,"anID",session("albumID")


    If the user needs to be aible to order more then one album, you can use a string variable and create a 'comma separated string' by adding the ID's each time an album was chosen (+ create an array with it and then use a loop for the select-querys)

    Or you could use multiple session-variables (ad them to the global.asa)

    session("numberordered")=0
    session("albumID1")=0
    session("albumID2")=0
    session("albumID3")=0
    session("albumID4")=0
    session("albumID5")=0
    session("albumID6")=0

    and store each ID in a new variable + keep track of the numer of albums ordered (to know witch session-variable to use to write the next album ID. probably best with a "select case" structure.)

    Does this makes any sense to you ?

  • #3
    mat
    mat is offline
    Regular Coder
    Join Date
    Jul 2002
    Posts
    199
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what is 'global.asa' ? is it a asp file or something? sort of like coldfusions application.cfm for specifying global app settings and variables.

    well i think it makes sense but i am still a bit of a newbie especially to CF so i don't fully understand. you are correct in terms of understanding what i'm trying to do though. perhaps i'll take it one bit at a time starting with the application file settings (i'm assumung that's what you mean by 'global.asa')

    / goes off to read up on CF application / session variable syntax

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    mat,

    you'll find more info about the global.asa at the folliwing adresses:

    http://www.w3schools.com/asp/asp_globalasa.asp
    http://www.asp101.com/resources/apps_sessions_gasa.asp
    http://www.haneng.com/Lessons_19.asp

    or

    http://search.megaspider.com/XP.html?global.asa+help

    for some other sites my search engine came up with

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It sounds like he's using ColdFusion (not ASP), but it also sounds like he's on the right track.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #6
    New Coder
    Join Date
    Apr 2003
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <cfset session.YourVariable = YourValue>

    thats it

    But if your not using cfmx lock your session vars !! <cflock>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •