I have uc_wishlist installed in Drupal 6.x and UC 2.x. It's allowing me to create the wish list but when I login as a user, search for a wish list and then add one of that wish list's products to my cart I get the following errors:
* You have selected to purchase more items than requested.
* You have selected to purchase more items than requested.
Any suggestions? It's not adding to the cart and I do have a quantity set on the wishlist side. So I've added a quantity of 1 or more to the # of product I would like. But then logged in as a diff user and then trying to add that product it doesn't work per above.
-backdrifting
Comment | File | Size | Author |
---|---|---|---|
#12 | uc_wishlist-492154.patch | 553 bytes | longwave |
#3 | uc_wishlist_SR_20090621.patch | 7.59 KB | cybertoast |
#3 | uc_wishlist_sr.tgz | 19.95 KB | cybertoast |
#2 | uc_wishlist_SR_20090621.patch | 7.64 KB | cybertoast |
#2 | uc_wishlist_sr.tgz | 19.95 KB | cybertoast |
Comments
Comment #1
cybertoast CreditAttribution: cybertoast commentedi'm having the same issue.
Comment #2
cybertoast CreditAttribution: cybertoast commentedThe source of the problem is the WantQty field being disabled for non-owner users. This thread (http://drupal.org/node/227966) has a discussion on the topic.
There appears to have been a change in form processing behavior between Drupal 5 and Drupal 6. In D5 the '#disabled' option to a form element would cause the value of the element to still be available when the element was disabled. In D6 this no longer seems to be the case. As far as I can tell this is a bug in drupal core.
So, what's the solution? This post (http://drupaleasy.com/quicktips/module-development-disabled-vs-readonly-...) has some thoughts on disabled vs. read-only. The readonly solution does not work. The solution is to add the '#value' option to the form element.
Following is the quick fix to the existing code:
In the uc_wishlist.pages.inc file, change the uc_wishlist_view_form() function:
In looking at the code I found a few other inconsistencies that made things more intuitive for the end-user. Instead of allowing the user to order more items than are requested (wantqty), why not just limit the form's input using a select box? This way there's no confusing error to the end-user, and the actual selection process is simpler.
I made the following change to accommodate this (also in the uc_wishlist.pages.inc file, uc_wishlist_view_form() function):
Changed to use a select-list instead:
Now the '#default_value' above has some sketchyness associated with it. If the #default_value uses the $item->qty-$item->haveqty logic, you'll have to change uc_wishlist_view_form_submit() to ensure that clicking one 'Add To Cart' button does not automagically add all items to the cart. The #default_value => 0 in the first block is based on a fix in a different post addressing this issue.
I've attached a patch here which has a set of changes I made to allow both singular and batch addition of wishlist items to the cart. I found it to be useful since I can test out how people respond to different options then. The patch includes a bunch of different things, so if you're not interested in all the features, please diff and only take what you need. But it incorporates all of the above discussion.
(BTW if you don't want to patch, and just want the whole bundle, it's attached as uc_wishlist_sr.tgz. Apologies to the module maintainers if this is not cool - please let me know if the proper code of conduct is to only provide patches).
Comment #3
cybertoast CreditAttribution: cybertoast commentedI screwed up my patch!!!
Please ignore the previous patch and attachment and use the one in this post instead. The problem is that I had a reference to $item->wantqty in uc_wishlist.pages.inc which does not exist (it should be $item->qty, in the form element default and value options).
Many apologies!
Comment #4
ambientdrup CreditAttribution: ambientdrup commentedAwesome! Thanks cybertoast. I'll try this out. Thanks for working on the patch.
-backdrifting
Comment #5
jasonabc CreditAttribution: jasonabc commentedam also experiencing this issue. Any chance cybertoast's patch can make it into a core release of UC Wishlist? The wishlist is rendered pretty much useless if people can't buy stuff from it...
Comment #6
jasonabc CreditAttribution: jasonabc commented@ cybertoast - many thanks for the module bud - works a treat!!!!!
Comment #7
koblongata CreditAttribution: koblongata commented// Why not just limit the user to the range of possible options?
$element['qty'] = array(
'#type' => 'select',
'#options' => range(0,$item->qty),
'#default_value' => $item->qty - $item->haveqty > 0 ? $item->qty - $item->haveqty : 1,
);
this part, i think it's more correct as this
'#default_value' => $item->qty - $item->haveqty > 0 ? $item->qty - $item->haveqty : 0,
Comment #8
manoz_79 CreditAttribution: manoz_79 commented+ Subscribing
Comment #9
gdblackx CreditAttribution: gdblackx commentedThis works now for when someone adds to cart but when you try to change the quantity wanted when you are logged in it doesn't work.
Please help.
Comment #10
gdblackx CreditAttribution: gdblackx commentedProblem solved. If you have this same experience this is how I fixed it.
Add the below code to the uc_wishlist_pages.inc page:
if($own){
$element['wantqty'] = array(
'#type' => 'textfield',
'#default_value' => $item->qty,
'#size' => 5,
'#maxlength' => 6,
);
}else{
$element['wantqty'] = array(
'#type' => 'textfield',
'#default_value' => $item->qty,
'#value' => $item->qty, // Necessary with Disabled
'#size' => 5,
'#maxlength' => 6,
'#disabled' => TRUE
);
}
Comment #11
gooddesignusa CreditAttribution: gooddesignusa commentedgdblackx what line #/ where ??
Comment #12
longwavePatch attached that fixes this issue.
Comment #13
longwaveFixed in uc_wishlist-6.x-1.1.