January 16, 200818 yr Hi everyone My client has asked me to come up with a shopping cart and I want to know how to build one up in Javascript, if anyone has any ideas let me know cheers
January 16, 200818 yr the best way would be a combination of AJAX (for ease of use) and PHP (for security). What you can do is set up the "add to cart" button as a link which goes to, for example : java script:addToCart( 62 ); where "62" is the unique ID number for that product. The addToCart function then does a POST request to this URL: backend.php?ajax=true&action=addToCart&productID=62 this backend.php page will recognise this (and other functions), and for this one, add the product ID to a cookie. The standard cookie layout is that of an array like so: Array( [23] = 1, [58] = 2, [62] = 2 ) Where the key ( in []) is the ID of the product and the value is the quantity required. The backend.php script could also return an XML (JSON etc) or plain HTML string which updates the on-screen cart details. If this sounds too complicated to achieve yourself, I am available to hire for such products so get in touch via PM.
Create an account or sign in to comment