Drag Drop Shopping Cart - PHP

Just discovered the the excellent script.aculo.us drag and drop shopping cart it is implelmented with the script.aculo.us javascript library and ruby on rails.
It is a perfect fit for a project I am working on but I needed a PHP version here is the rough first draft with source code,

57 Responses to “Drag Drop Shopping Cart - PHP”

  1. mindrape Says:

    Spiffy! I’ve seen the Ruby on Rails version and you did a nice job emulating it!

  2. ludix Says:

    thanks! your examples really inspire me!

  3. BJ Says:

    This is really cool. I was ‘drawing it on paper’ looking at building a prototype for a client, but what if the page scrolls with products?
    I know your example wasn’t meant to be a solution to this, but I thought I’d bring it up in case anyone (including myself) can think of a possible simply solution.

    It may be more cumbersome to have Drag/Drop all the way to the top of the page. This is where clicking ‘Add To Cart’ would make more sense.

    I guess this would be a great solution as well for CMS where you have a grid of records and you can drag and drop into a wastepaper basket….(Of course they wouldn’t delete) until you hit DELETE button. Hmmm. Maybe I’ll do that for now.

  4. Santiago Says:

    Hi, I got some questions:
    1)- It’s possible to obtain products from a Date Base, showing 10 products per page?
    2)- Make a check out button to Email all Products Added to the Cart Box to deliver?

    Well i have to say that i’m not speek english so well but i wanna tell you that your example it’s the best… i have been searching for somthing like this on Ajax Aplications and nothing works like I want.

    Thanks!, Cheers!

  5. Steven Says:

    Wonderful example ;

    How can i get this working on my machine? I’ve got all the code and files, do i need to set up a db connection?

    or are you able to .zip it all up?

  6. meneame.net Says:

    cientos de ejemplos en AJAX listos para ser usados en tu site

    Encontrado en el site de emily chan (ehub), es un site con cientos de códigos AJAX disponibles para ser usados.

  7. CSS Lab » Aplicaciones AJAX listos para usar Says:

    […] JAX por Administrador el 31 de January, 2006

    Urgueteando por la web, me deparo con un link donde se encuentran scripts, algunos usando la librería Javascript script.acu […]

  8. Tyroga Says:

    Hey BJ,

    You could always try a floating div that moves down with the scroll of the page, that could be your cart? While the images are cool to have in your shopping card you could just have text to save space.

    ty

  9. All Forces » Blog Archive » Random Links Says:

    […] ind. Nacho Libre Trailer Jack Black as a luchador. Doesn’t get any better than that. Drag and Drop Cart in PHP Tom Westcot has made a PHP version of the infamous […]

  10. WackyQuote Says:

    Interesting site and good information.

    I just put up a new site that uses AJAX combined with IFRAMEs. (http://www.wackyquote.com) It’s a blog toy that people can add to their sites. I used AJAX to allow interactivity with the users without page reloads. It was a fun project to do. I think all my web projects from now on will involve AJAX.

  11. Stan Says:

    This is cool, nice work.

  12. kawin Says:

    that’s awesome!!! really. the best Ajax example I’ve ever seen. Also the username check one is excellent too. you rock mate! :)

  13. Ralph Posadas Says:

    Does anyone want to undertake a BETA of this Drag n’ Drop shopping cart? If so let me know because I have a company who can promote and sell it. Email me at ralphposadas@cacninc.org for more details.

    Great scripts!

  14. David Says:

    Is there anyway someone could translate the PHP version over to ASP version?

    Thanks,
    David

  15. Khaqan Says:

    Hi,

    Here is a more practical implementation of our drag drop script:

    www.soundcrafts.co.uk . Please see that you can drag and drop items into cart, delete them, and checkout.

    Waiting for your comments :)

    Thanks,
    Khaqan Mahmood,
    Artologics Software
    www.artologics.com
    Easy Ecommerce Stores

  16. unu Says:

    it doesnt work for me :(
    when I drag items in to the cart - they won’t show up there. just empty cart…

    do I have to change something in php.ini ?

  17. Dan Says:

    @unu copy all the js file, and do not rename de cart.php file. Some Ajax functions use the name. Good luck!

  18. unu Says:

    I renamed cart.php to index.php - and seems that was the problem

    thanks Dan!

  19. Ignacio Says:

    =)

  20. rakesh Says:

    hey,

    That was ann awesome piece of code..wonder what those javascripts look like…

  21. Satya Prakash Says:

    Great Example and easy way of demostration.
    It is great.
    regards
    Satya Prakash

  22. Khaqan Says:

    Please see our version of drag drop shopping cart on www.soundcrafts.co.uk

  23. Drew Says:

    hi I am a website designer, I dont know much about coding alittle html here and there and sometimes i dabble in javascript. I like your solution the drag and drop feature, when i showed it to some of my clients they went nuts and said they needed it.

    I was wondering if you could provide this solution to me and my clients on a per client basis, I promis to credit you with a developed by page on all my clients websites.

    How well does your drag and drop work with thousands of products with thousands of images. do the PNG files get to be quite large and cumbersome. not that I would have more than say 20 products on a single page but i was just wondering to what extent have you tested it, is it scaleable?

    thanks,

    Drew Dupont
    Organic Photography & Website Design
    1723 Olive Street West
    Stillwater MN 55082

    (612) 807 7045

  24. Drew Says:

    I was testing your version and found that once you exceed the amount of items beyond the size of the shopping cart/ however unlikely in reality it simply extends beyond the boundry. Also for ordering multiples of the same item say i wanted 20 t shirts for all the people at my office ect. ect. adding 20 t shirts is cumbersome one at a time , wondering it you could impliment a right click feature inside the cart that you can change the quantity and have some sort of scroll or summary icon to represent larger numbers of items that dont fit within the peramiters of the shopping cart due to volume.

    get back to me whenever

    Drewdupont@gmail.com

  25. dj Says:

    I love this demo!
    Thank you!

    What should I do if I would like to handle more cart on a page?
    How can I send parameter that in which cart made the user his modification?
    Now we send just one parameter that which element add or drop, but I would like to send the ID of the cart, too.

    Thank for helping me!
    dj

  26. Mario Says:

    I noticed that this script has Problems in Internet Explorer…have you guys noticed that?

    Sometimes it is hard to replicate the problem, sometimes it does it on the first try…you can try repeating me to see. All I do is add a few items into the cart, and then I drag them into the garbage in different locations in the trash and eventually it won’t let me drag from the cart to the garbage again…it won’t let me click on the items and move them. It WILL still let me drag/drop the main items, but not the ones in cart.

    Any ideas why? Firefox is perfectly fine.

  27. Mario Says:

    As I said before this is hard sometimes to replicate but it does happen…I rebooted the computer and even tried the Scriptaculous version and it also had the same problem, so not just this PHP version of the code. It is as if I lose the ability to select the item in the trash…I can right click on it and it know there is something there, but I just can’t move it anymore.

    Regarding my previous post, where I detail how I got the error to come up…if you can’t do it by simply dragging then do this: pic an item in the cart and just let it go, do it for a few of them, some you drag to the trash, some you just pick up and let go…eventually you can get it not to react at all to you. This is hard to explain in text but I’ve been able to replicate it several times but only in IE.

    Thanks.

  28. JOiL Says:

    Really nice work!!

  29. theguiblog » Blog Archive » AJAX Shenanigans! Says:

    […] During my exploration of AJAX techniques, I came across a like-minded individual who loved the Ruby on Rails version but needed a PHP version.  Since I am still learning, I took a look at the PHP-version source and customized it….just a little. […]

  30. Riddler Says:

    FANfuckingtastic mate, great job… well done!

  31. GaryB Says:

    Further to the internet explorer problem. I am encountering similar problems with IE. I have tracked it down a problem with dragdrop.js . When I drop an image to the drop area / cart and refresh a windows error informing me that IE “cannot open the internet site http://sitename. operation aborted” is displayed. You then have to close IE before you can access the cart again. Everything is fine in Firefox.
    I found a posting which seemed to be the solution for me but unforunately this didn’t work form me.
    Any thoughts would be appreciated.
    Oh yes, forgot to say that it is a realy nice script.

  32. GaryB Says:

    Further to the internet explorer problem. I am encountering similar problems with IE. I have tracked it down a problem with dragdrop.js . When I drop an image to the drop area / cart and refresh a windows error informing me that IE “cannot open the internet site http://sitename. operation aborted” is displayed. You then have to close IE before you can access the cart again. Everything is fine in Firefox.
    I found a posting which seemed to be the solution for me Transcraft but unforunately this didn’t work form me.
    Any thoughts would be appreciated.
    Oh yes, forgot to say that it is a realy nice script.

  33. sriram Says:

    I am looking for a an example that will allow me to build a mobile version of a page by dragging elements from one list and dropping onto the other without deleting the items from the originating list. So, basically it is similar to a photoshop toolbox or a visio stylus on the left hand side and when I drop it onto another list/column, it should transform into the corresponding HTML elements that I can edit.

    Could someone please point me to an example? Any help greatly appreciated.

  34. Phil Markey Says:

    Help!
    I’ve made a shopping cart that uses the script.aculo.us library. You can see it here: http://www.trebrown.com
    I don’t use IE, I don’t intentionally build with it in mind but I’ve discovered that there are some IE bugs somewhere in my scripts, but I have no idea where to start. If anyone can hint at what might be causing them I would be most appreciative.

    First one =
    Line: 32
    Char: 1
    Error: Object doesn’t support this property or method
    Code: 0
    URL: http://www.trebrown.com/shop/index.php

    Second = (This one apears to be in prototype.js)
    Line: 1023
    Char: 5
    Error: ’style’ is null or not an object
    Code: 0
    URL: http://www.trebrown.com/shop/index.php

    Now on that first page “shop/index.php”, which is just a demo both those errors occur but on all other pages that have drag and drop only the first error occurs.

    Now I can give you more information, but I’d like to here some of your guesses if I may?

  35. seraphimpunk Says:

    love the silly easy shopping cart.
    I’ve been trying to resolve it with another drag and drop library though so that the cart can be sorted ( i’m not using it for an ecommerce implementation ), so i’m looking for a way to integrate the sorting in two dimensions from http://tool-man.org/examples/sorting.html with your silly easy shopping cart. But i’m better at php than with javascript. So I was wondering if you ( or anyone ) has any pointers on how to go about doing such an integration between the two scripts.

    I have a test page set up at home which just tries to use both scripts at the same time, and while it doesn’t cause any errors on the page, it doesn’t work either.

    any help/advice appreciated.
    thanks

  36. jess Says:

    What if you want to link the items? EG if you click ‘mug’ you get a close up of ‘mug’ in a new page.
    The problem is this:

    the onDrop function fires the image’s link and not the Ajax.Updater. This happens with both href and onclick. Is there a work around?

  37. SaVaTaGe Says:

    Prototype Carousel is great withAJAX support, We hope a PHP version of this, modified with xajax not prototype :)

  38. Ronald Says:

    Very good your scrit to served to me as much! I been implementing and I to had left but wanted very well to do it far better but I have a problem: When putting the picture within a Div called by AJAX the picture does not move …… I assume that there is to make some change in the container of picture in some of the Js archives. I am in the certain thing? where I can make the changes? or it is not possible to do it….

  39. Tony Says:

    Fantastic example! My client wants exactly this functionality for his new shopping cart but the coding is way beyond me. Here is the spec:

    Drag & drop cart
    Checkout goes straight to PayPal without requiring user registration
    Probably no more than 20 or so products
    Simple as that

    Is anyone interested in developing this or perhaps helping me to develop it?

  40. Eetu Says:

    Hi,

    Could you help me a bit. I just loved the script but making the checkout is not included on that you mentioned there that you used the script some where? could you give me a suggestion which would be the best way to do the check out part and sending an invoice…

    the script would be used in one cloting shop and one publishers webshop.

    thanks in advance.

    Regards,
    Eetu

  41. theanswer Says:

    how much would you give me for the answer? I already have this software ready for sale.

  42. weiss Says:

    i love you. thank you SO MUCH FOR THIS. you have no idea how much of my ass you’ve saved.

  43. Sampath Says:

    I would like to use drag and drop,slider bar components in a jsp (developed using Java Server Faces) pages. So can i have the code for that.

  44. Reverse Auction Says:

    very nice interaction. Keep pushing and develop new application like this one, it really helps the web and make it easier for users…

  45. morpheus Says:

    Hi,
    very good work!
    I was trying to use it for my project but when I drop an item it tells me “You don’t have permission to access /cart.php on this server.”
    and

    “Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    Apache/1.3.37 Server at www.xxx.com Port 80″

    Do you know if I need any specific server configuration? I copied cartp.phps and renamed it to cart.php, and copied everything in the folder shop_files.
    Am I missing something?

    Thanks a lot

  46. Juan Says:

    Excellent, this is something i was trying to do for an application, not exactly the same but very similar and this just have saved me a lot of time. I’ll get sure to return here once i make some profit.

  47. Diabolik Says:

    Hi All,
    I think what I’m about to ask sounds very simple….but I had no lock yet.
    What I want to do, starting from the MultiList D&D (http://www.cyberdummy.co.uk/test/dd.php)
    is to CLONE the objet instead of MOVING IT.
    I’ve tried to comment out:

    this.parentNode.removeChild( this );

    in dragdrop.js but… no luck.
    Any help is greatly appreciated!!
    Fab

  48. Red Says:

    Any idea how you would assign values to the products on a basic level with no mysql and spit out a total? I am drag and drop a quote form for services, but i need a price to show at the end!

  49. Adam Says:

    Awesome script..

    However I’m having 1 problem. I copied the script files needed and loaded them on my local server. Everything is working properly except the calculations. When ever I drag a new item to the cart it replaces the other. If its the same item it will add it correctly tho. But I can’t have different items in the cart at the same time.

    Any suggestions?

  50. shine Says:

    Great effort ! Nice integration and smooth running.

  51. lee Says:

    It is a nice demo page. I am an ASP.NET guy and don’t know PHP. But, I learned it through the demo plus the scripaculous drag n’ drop functionality. Is it possilbe for you to me the style.css file that is linked in this demo code.
    Thanks,
    -Lee

  52. lee Says:

    Never mind.
    I got it from it from the path.

  53. smarf Says:

    It’s been some time since this was first posted…surely there are some smoking implementations of drag and drop carts with automatically tabulated checkout totals etc. Does anyone know of any sites?

    Thanks…

  54. lanlan Says:

    I changed the wastebin div to the div of my main content and the products div is a fixed div on the bottom of the page. But it’s only working in Firefox. Any ideas?
    Thanks in advance.

  55. priya Says:

    nice work…..it is of great help to me

    but 1 thing i cant get is that the items are being added in the cart in the form of array..I want script such that items r added in the cart in 1 row only

  56. Brad Says:

    Im having so many problems with my websites shopping cart and im interested in the drag and drop cart. does anyone have any info on how to obtain one on my site. My stores URL is http:www.jokersracing.com any feedback??

  57. Graham Says:

    Hi all - just found this blog and thought you’d like to see how a wordpress site looks with an e-commerce plugin that offers the drop shop facility- Its just been officially released the site and in final stages of testing / cleaning up. www.wadsworthkawasaki.co.uk
    Interested in what you think?
    Merry Christmas
    Graham

Leave a Reply

-->