Search code examples
drupaldrupal-6

Ubercart, replacing quantity input text with a dropdown box


I'm using the Ubercart car and I would like to replace the input field to specify the product quantities with a dropdown box.

In this way, customers don't have to type the number of items they want to buy but they can just select an item in the dropdown popup: http://dl.dropbox.com/u/72686/dropdown.png

How can I replace it ?

Thanks


Solution

  • You can try this in hook_form_alter().

    if ($form_id == 'cart form') {
       $x = 0;
       $options = array();
       while ($x < 50) {
          $options[$x] = $x;
          $x++;
       }
    
       $form['qty']['#type'] = 'select';
       $form['qty']['#options'] = $options;
    }
    

    I did this off the top of my head, but it should work.