I can choose any value I want on the cart page, and the only point at which I'm alerted to an out-of-range value is when I try to go to the checkout page. I'm not sure what the right strategy is, given Ubercart's preponderance of hooks, but it seems like you should be able to add a custom validation function via FAPI.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 921850-uc_product_minmax_cleanup-2.patch | 19.77 KB | neilnz |
| #1 | uc_product_minmax_cleanup_0.patch | 18.61 KB | HorsePunchKid |
Comments
Comment #1
HorsePunchKid commentedAttached is a patch that fixes this problem and numerous others. I'm sorry it's not a more targeted patch, but it was difficult to get done what I needed without touching a lot of the rest of the code. Here are some of the changes:
* Prevent "Add to cart" from working if it would cause illegal quantities in the cart.
* Allow a minimum of zero (i.e. no minimum)
* Significant collapsing and refactoring of redundant code (20 fewer lines despite increased functionality), e.g. a function to load minmax values based on a nid
* Better error messages
* Proper indentation and Drupal code conventions
It needs more testing, but it seems to be working well for me.
Comment #2
neilnz commentedI had a couple of issues with your patch, so here's a revised one with:
Otherwise nice patch, thanks!
Comment #3
arski commentedthis is awesome!
Can I make a related suggestion - maybe it could be possible to remove the quantity field completely if min=max, i.e. if one is only allowed to buy X of one item, not more not less - the field and the whole validation stuff then becomes kind of pointless.
Otherwise this is great! :)
Cheers
Comment #4
arski commentedhey again,
First of all, there is a line like "$message[] = 'test';" in the patch, which should really not be there as it prevents any kind of addition to the cart.
Another thing is that sadly this patch doesn't do it for me :( I can still update the cart with invalid quantities, and they only get caught when I proceed to checkout.
Thanks in advance for fixing this!
Cheers
Comment #5
arski commentedHey,
found the issue: in the new function uc_product_minmax_cart_validate, you're 3 times referring to
$minmax->multiple
whereas it should be
$minmax->pmin_multiple
Do you mind fixing that please as I'm too lazy to create two instances to do a new patch.. thanks! :)
Comment #6
fred0 commentedThanks all for the patches and reports.
I implemented these changes and fixed a few minor issues as noted and that I found..
Additionally, the uc_product_minmax_form_uc_cart_view_form_alter function from HorsePunchKid's patch works for both cart update and checkout and made the original (from the 2 UC 1.0 modules I merged to make this one) cart validation code redundant. I removed that older code so, please test and let me know it works for you.
Comment #7
fred0 commentedAll,
I am working on the D7 port and have a couple questions.
First, what is the purpose of the a minimum of zero? I implemented it in D6 with the patch, but I'm not sure why anyone would want that.
Second, to arski's suggestion that we remove the qty field on the product page if min=max, since that would also have to rely on the uc default add to cart value, does anyone have an opinion on if this is truly a useful feature (it would have to work if min=max=default add to cart) or is does anyone think that having to set a value outside the product feature interface just add confusion?
Thanks!