Nothing happens after "add to cart" is clicked
grendzy - November 20, 2008 - 19:40
| Project: | Ubercart Donation Products |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Description
Hi, I just installed the new uc_donation port for 6.x. Thanks for your work on this!
When I enter a donation amount, and click "add to cart", nothing happens. It just refreshed the donation product node.
Poking at the code a bit, it seems that uc_donation_add_to_cart_form_validate() and uc_donation_add_to_cart_form_submit() are never called.

#1
I did some work with this, and I believe it is now working on Drupal 6.
The main changes I made involved updating function signatures which have changed from Drupal 5.
This also resulted in needing to change the way some variables are accessed in arrays.
The biggest change I made is that I am now setting #validate and #submit as part of constructing the add to cart form. This ensures that the correct functions are called for validation and submission of the form. I am not sure, but I suspect that this may mean there is no longer any need to append the nid to the form name. However, I have left that functionality in place since I am unsure whether it is unnecessary.
Finally, I removed a string replacement from the add to cart submit handler because it was redundant with the same replacement being done in the validate handler. Since $form_state is now passed by reference, the change made in the validate handler persists, and thus does not need to be done again in the submit handler.
Hope the attached patch helps.
#2
Thanks! I came up with something similar. I also had to comment out a section in uc_donation_cart_view_submit(). The cart update form displays in the wrong place -- I believe because hook_table_alter no longer exists.
#3
Thank you for both your work, though I have halted making updates to the module for Drupal 6 until the issue grendzy mentioned about the cart update form displays in the wrong place because hook_table_alter is deprecated. The same issue prevents the field from showing in the catalog as well. There is a method to display these correctly but it is a work around to an existing problem with the current Drupal 6 version of Ubercart. For more information on the issue check http://drupal.org/node/335673. Once this issue is fixed, I will again work on updating the module.
#4
I just heard from Ryan over at the Ubercart forums that he was "95% sure" that Tapir had been finalized. Any hope of resuscitating this project? It's an AWESOME module; just want to have it good for D6....
#5
Try this....
It seems to work so far...
try adding this:
$form['nid'] = array('#type' => 'hidden',
'#id' => 'edit-nid',
'#value' => $node->nid
);
just above
$form['#validate'][] = 'uc_donation_add_to_cart_form_validate';on or about line 110 of uc_donation/uc_donation.module.
It now adds items to cart... though I can't edit the cart or delete them from it... oddly.
#6
I haven't had a chance to test the Dec. 3 release, but it from the commit messages it looks like this might be fixed:
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/uc_donation...
#7
Thanks for the reply, Grendzy.
Unfortunately, it isn't fixed.... with the version above, items will not add to cart unless one adds the code-fix I mentioned
$form['nid'] = array('#type' => 'hidden',
'#id' => 'edit-nid',
'#value' => $node->nid
);
and the cart won't delete or edit products...
I am a bit at wit's end here. I think this could have to do with the D6.8 Upgrade?
6.6 users might not to have the same issues.
I just can't track this one down..
#8
A patch has been submitted in #8 at #341819: Allow contrib modules to utilize uc_product_add_to_cart_form that allows donation products to be successfully added to the cart in Drupal 6 and Ubercart 2.
The Ubercart developers haven't been replying to that issue as of late so any help there in getting their attention to commit the patch would benefit uc_donation greatly and any other module which creates their own product type.
#9
This now works as of todays dev release without needing to patch anything.
@acb your solution would have only suppressed the error but did not fix the issue. The problem was that a function could not be found for the unique form_id of the donation product due to #341819: Allow contrib modules to utilize uc_product_add_to_cart_form. A work around has been used to squash this issue.
#10
Automatically closed -- issue fixed for 2 weeks with no activity.
#11
Same problem as above: nothing happens after "add to cart" is clicked.
Tried beta2 first, then the dev release, which #9 mentions should work.. but it does not.
Any ideas, please? We cannot use this module at all if adding donations does not work.
Thanks for any feedback --
#12
Do you get any errors? Do you have regular products and do they add to cart like they should? Which 'add to cart' doesn't work if not both, the one on the node view page or in the catalog?
#13
Hi, thanks for coming back on this.
We have a donation as a product set up in UC. After selecting it in the dropdown at /admin/store/settings/donate/manage/donation and clicking 'Add' the page changes to /admin/store/settings/donate/manage which says 'No donate items have been added.'
I've just tried it again, watching whether there were any errors generated in the server log but there weren't any.
If you need more info, don't hesitate to ask, I am happy to help with testing etc, of course.
#14
I will be releasing a beta3 today, if you could try that. I can't seem to replicate the problem you are having. You might try resetting the drupal cache.