Update @ 2015-04-27: There is a simpler way to achieve this without coding. Please refer to this comment.
In the Ubercart product page, the product quantity option in the add to cart form is hidden by default. If you want to allow user modifying the product quantity in the order, create a custom module and implement the following hook.
/** * Enable quantity field in add to cart form */ function <your_module>_form_alter(&$form, &$form_state, $form_id) { //print($form_id); if(substr($form_id, 0, 28) == 'uc_product_add_to_cart_form_') { $options = array(); for ($i = 1; $i <= 10; $i++) { $options[$i] = $i; } $form['qty'] = array( '#type' => 'select', '#title' => t('Quantity'), '#default_value' => '1', '#options' => $options, ); } }
A selection list will be shown with 1 to 10 options in the add to cart form.
Done =)
Reference: Theming Add To Cart form – attributes and quantities
Just stumpled upon this. Thanks for sharring. I need to have the quantity on the catalog page. If I use this hook I get the quantity in the form, but when I submit the form, the qty is set to 1 no matter what i select. Do you have any clues as to why ? qty works fine on the product node view, but not in the catalog view… I am using ajax driven cart…
Any help much appreciated 🙂
/T
LikeLike
what do u mean by the catalog page? is it a custom page or the default products page by Ubercart which is http://<drupal>/products?
LikeLike
Yeah – its the catalog page provided by ubercart, wich is at /catalog – ie : http:///catalog/2
I just solved this by overriding the submit handler for the uc_catalog_buy_it_now_form.
/T
LikeLike
I just realize that actually we can add the quantity field to the add to cart form without coding. Just enable the Display an optional quantity field in the Add to Cart form @ Adminster -< Store administration -< Configuration -< Product Settings.
If you want to add the quantity box @ the catalog page, just edit the uc_products view as follow.

LikeLike
Do you mind editing the post itself to reflect this? Google still links to this page and I just spent an hour searching before finding this flag on my own. Cheers.
LikeLike
I am sorry about that. I have added a note to the post about this solution. Thanks for your suggestions. =)
LikeLike
Yeah!!! Yahoo. I’ve been messing with this on and off for days, and that’s it. Thank you both.
LikeLike
you are welcome =)
LikeLike
Wow, talk about intuitive (NOT!), but that did it for me too. Who would have guessed that “Product: Add to cart form” contained the Quantity field?
Thanks ykyuen!!!
LikeLike
Good to know that i could help. =D
LikeLike