si-blog

ColdFusion shopping cart

Posted Jan 21, 2004 in ColdFusion.

I am working on a project that is going to require a very basic shopping cart, written using ColdFusion MX. I am using Dreamweaver MX, and working with the standard master/detail pages as far as products are concerned, but I need to figure out a way of letting users fill a session-based cart. After that, I intend to send the total to a single-item PayPal setup, so I don't need to deal with credit cards, etc.

I'd be grateful if anyone could give me some advice, or point me to a book or site that can help me out.

Comments

  1. Gravatar

    Basically, all you need is session management via the application framework (see cfapplication) and a bit of advanced data structures perhaps like so:
    <cfset session.aCart = arrayNew(1)>
    <cfset session.aCart[1] = structNew()>
    <cfset session.aCart[1].sku = '0001'>
    <cfset session.aCart[1].qty = 1>

    hth, AE

    Posted by Andyed on Jan 22, 2004.

  2. Gravatar

    Thanks, Andy. I must tell you that my experience with ColdFusion is somewhat limited, but as far as I can tell you are suggesting that I should store a shopping cart item in a structure, and then store those structures as an array, correct? I looked into session side of things, and it looks fairly straightforward from that point of view.

    I'm putting the cart side of things on the back burner while I deal with everything else. Thank you very much for your advice.

    Posted by Simon Jessey on Jan 22, 2004.

  3. Gravatar

    Right, when it comes time to send to paypal:

    <cfloop from="1" to="#arraylen(sesssion.aCart)#" index="i">
    do some stuff with #session.aCart[i].sku#
    </cfloop>

    Posted by Andyed on Jan 23, 2004.

  4. Gravatar

    there are some carts written in CF to give save you a lot of hastle. But cartweaver www.cartweaver.com is shite.

    Posted by jack on May 14, 2004.