Re: Add to cart using ajax

Posts: 1
Joined: 07/09/2008

Doesn't the uc_aac module do this or get you close? http://www.ubercart.org/contrib/2010

Well I guess technically, there is still a full page reload from what I can see. I've got my test site setup with uc_aac and no redirect set for the Cart settings and that automatically updates the cart when the add to cart button is pressed. This still does a page reload, but stays on the same page.

From what I can see without really digging into the code (I'm still familiarizing myself with Drupal and Ubercart) is that either Ubercart's behavior needs to be changed so it doesn't do a page reload when adding to the cart and just let AJAX and JavaScript do the work or, and this is where I don't know what can and can't be done, a module needs to be created that overrides the core default behavior so that the redirect doesn't reload the page, or it just doesn't redirect at all.

Personally, from looking at the Cart settings, the way I read it is if you set the redirect to <none> it should do just that, no redirect, thus no page reload. Maybe add another option of <same> where it does do a redirect and reload to the same page so that the <none> setting does what it insinuates "Enter <none> for no redirect."

Ryan, if you're still following this thread, could you post an example or a link to an example of using hook_form_alter()? I've only just started digging into the Developer's guide, but I'm no programmer, just a hack, tech geek.

I guess I just don't understand. If I or someone creates a new module, would they be overwriting some of the behavior of the uc_cart module? Would they need to specify new functions for uc_cart_form_alter and uc_cart_add_item? Well after doing a bit more digging, I think I'm understanding a little more.

A new module that would actually be pretty small and just and pretty much have a "uc_cart_ajax_form_alter" function that would be watching for "add to cart" and not do a redirect?

I think I've got more reading of the code, documentation and some testing to do....

Add to cart using ajax By: dolittle (8 replies) Wed, 03/12/2008 - 05:27