I'd like to see the qty restriction configurable for product classes so that you can set a class to have a default qty restriction. I am using this for "course registration" and it never makes sense (in our business case) to allow a user to buy more than one (at a time, or ever, though that is a different story for a different feature).
What I am suggesting is that when you create a new product class you would be able to set a default restrict qty value for all products of that product class, though you could override it on a per product basis.
One other thing is that it would be great to have the option to "hide qty if qty restriction is 1" in order to hide the qty from the cart and confirmation screens.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | 416422-default-for-product-classes.patch | 12.37 KB | hanoii |
Comments
Comment #1
greenbeans commentedI'd be interested in this too. Going to check out the code and see if I can make heads or tails of how to implement it.
EDIT: Looks like this might be easier to implement entirely separately than to graft onto this module.
Comment #2
mrfelton commented@greenbeans: Why do you say that? This module is specifically for restricting quantity. New features (including this one) should be added to this module, not created separately, elsewhere. I will try to look into adding this over the next week.
Comment #3
mrfelton commentedMarked #404426: Restricted Quantity should be parameterized as a duplicate.
Comment #4
greenbeans commentedSorry, I meant more that I didn't see a way to do it by reusing the functionality already in the module, not that it should be in a separate one. Let me know if I can help you at all with the implementation.
Comment #5
mrfelton commentedPlease see notes at #348049: Configurable Qty for initial development of this. IT doesn't yet provide class defaults, but does let you configure the quantity at the product level. Please test and report any problems over at the other thread.
Comment #6
timani commentedPotential solution for this while something more comprehensive comes about.
I'd like to see the qty restriction configurable for product classes so that you can set a class to have a default qty restriction. I am using this for "course registration" and it never makes sense (in our business case) to allow a user to buy more than one (at a time, or ever, though that is a different story for a different feature).
With this module you can go the "Product/Plan" and go to the features, and click the checkbox to empty the cart.
http://drupal.org/project/uc_atctweaks
I have a custom template for the content type i wish only to be purchased. I guess you could hide the add to cart or a redirect based on content type or have that taken care of inside the template
Hope that helps
Comment #7
GregoryHeller commentedI don't think that the patch or notes in http://drupal.org/node/348049 Configurable Qty really address the issue raised in this ticket, which is to allow for default qty restrictions on products and specifically by product class, which is not to say a total cart restriction, rather a specific product restriction.
Currently the act of adding a restrict qty feature to a product requires that the product creator go to a completely different tab and add this feature thing. I understand for extensibility purposes, perhaps, why restrict qty is a product feature, but it would be far more user friendly if the qty restriction was included in the main product information field set for every product as opposed to obscured on some separate tab.
Comment #8
jamesialford commentedI would like this feature ass well. Is there any updates on this?
James
Comment #9
kostajh commentedsubscribing
Comment #10
mautumn commentedSubscribing. It would be more useful if the qty can be specified - not fixed at 1, on a per product basis. Keep up the good work!
Comment #11
tiuman commentedPLEASE I NEED IT!!! Add Default Qty Restrictions to all default products!!! tiuman@mail.ru send me please !!!
Comment #12
Anonymous (not verified) commentedFor my needs, which is every product has a lifetime quantity restriction of 4, I've created a custom action which I set to trigger whenever a node is added. I thought I'd post the code here as it may be useful to some.
You'll need to create your own custom module and add these functions to it - I've commented where you need to change stuff:
Comment #13
Anonymous (not verified) commentedLet me try that again - I left in my content type of 'showing' in the code, here's amended version:
Comment #14
Anonymous (not verified) commentedOh man I need sleep, noticed another error (not critical, only textual!):
Should be;
...or whatever your quantity restriction is.
Right, bed....
Comment #15
carsonwstevepurkiss, I created a custom module and implemented your code but I can't get it to work, for the life of me. Would it be possible for you to simply share your module as an attachment (zip) and I could go in and simply edit the node type and quantity?
Comment #16
carsonwOr, I wonder what the php code would be to run to simply add the "Restrict Qty" feature to a product using the "Rules" module... this may be a simpler alternative.
Comment #17
alexkb commentedI couldn't get stevepurkiss's code to work either.
As a work around, I deleted all the rows in uc_product_features that mentioned 'restrict_qty', and then batch inserted all those that I wanted, i.e.:
(where is the name of the node type you want).
For products added into the future, I just used the following code:
Hope that can help someone! Seems to work fine.
Comment #18
EvanDonovan commentedAm I correct in my reading of this issue that no one has submitted a patch for the module yet? stevepurkiss' code, while potentially useful, seems to be more of a workaround than a fix for the underlying issue. alexkb's code is much cleaner, and closer to the correct fix.
I think that the actual fix would do the following:
I don't have the time to code this right now, though I would review if it were available. I will just use a modified version of #17 for the time being.
As for doing it using Rules, that would make the node types customizable, and the PHP code would be, I think, what is inside
case 'insert':in #17.Comment #19
EvanDonovan commentedBy the way, I tested the code in #17 with the following condition:
if ($node->type == 'registration' || $node->type == 'product') {Works great!
Now someone just needs to write up a patch, and add the variable setting logic as I described in #18.
Comment #20
summit commentedSubscribing, greetings, Martijn
Comment #21
Anonymous (not verified) commentedAlso subscribing...
Comment #22
hanoiiI created a patch for this feature, I did it so on 2.x though.
This patch follows the ideas of #18 plus a few more stuff:
- It lets you define defaults on product classes
- It insert the feature for the specific nodes on creation
- It has a batch process allowing you to add the feature to all the nodes that doesn't have it or overwrite everything.
- It fixes a function that should be removing the internal information from the db on node deletion for the proper nodeapi hook.
- it adds fields to the uc_product_classes table using using the proper schema/install/uninstall hooks.
Any help reviewing this is appreciated.
While going through this I got a pretty good picture on how the module works so I will request to owner of this project to become a co-maintainer, I can commit fully to this but one more hand might help a little.
EDIT: NOTE: You need to run update.php after patching the module
Comment #23
hanoiiForgot to attach the patch.
Comment #24
EvanDonovan commentedThanks, hanoii! We went live with my version of #17, so I don't have time to review at the moment.
We might be developing another site with the same use case, though, so I may have a chance to review at that time.
Comment #25
deadcataudio commentedI applied the patch to 6.x-2.x-dev but I get an error while trying to apply QTY 1 in my Product Class:
user warning: Unknown column 'uc_restrict_qty_default_qty' in 'field list' query: uc_restrict_qty_uc_product_class_form_submit /* sfxadmin : uc_restrict_qty_uc_product_class_form_submit */ UPDATE uc_product_classes SET uc_restrict_qty_default_qty = 1, uc_restrict_qty_default_lifetime = 1 WHERE pcid = 'MYPRODUCT' in /home/www/site/html/MYSITE_com_root/sites/all/modules/uc_restrict_qty/uc_restrict_qty.module on line 401.
Did somebody else tried the patch?
Comment #26
hanoiiI was about to look into this, you need to run update.php file after patching the module, because it adds fields to the product_classes table, that's probably why your query is failing.
Comment #27
deadcataudio commentedThanks, that was the problem - I had a php memory problem thats why the update got stuck in the frist place - disabled some modules, ran update again and - voila :)
Thanks for the quick help and the great time saving patch!
Comment #28
jdmyron commentedSo, are the default quantity restrictions in the dev version now or no? Still only available via a patch?
Comment #29
strr commentedSo, are the default quantity restrictions in the dev version now or no? Still only available via a patch?
Comment #30
strr commentedSo, are the default quantity restrictions in the dev version now or no? Still only available via a patch?
Comment #31
strr commented"It has a batch process allowing you to add the feature to all the nodes that doesn't have it or overwrite everything."
Where and when is a batch done to update all products of a contet type to have restrcition of e.g. 1 item
Thank you.
Comment #32
strr commentedHello,
i applyed the patch successfully and run update.php
I enabled and restricted to "1" at admin/store/settings/products/edit/features
But nothing is restricted when i add a product to the cart.
Are there any other settings i need to do - what have i missed.
I cannot restrict anything even without the patch?
Thank you
Comment #33
hanoiiIt's been a while since I used this module and submitted the patch. By looking at it, there's an option in the product class form in which you set the default, to batch add the restrictions to the products, that should work. Otherwise I am not sure I'll be able to look into this unless the maintainer is willing to accept this patch, in which case I might try to push it a little bit forward, but It was working for me.
Comment #34
raulmuroc commentedThat's currently included in the stable version.
Search for:
" Default maximum limit for a product " in the Ubercart Restrict Qty UI.
Comment #35
NamesBuying.com commented#22 & #23 works for me, thank you hanoii .
After I search the internet and drupal for 3 days , this patch only works for me properly!!
Comment #36
vmtrinka commentedVoila !! There is a module for that !!
https://www.drupal.org/project/uc_restrict_qty
Comment #37
joe huggans@vmtrinka - this module doesn't allow restriction per product class. I'm looking for a D7 solution if anyone knows of one