As well as allowing users to add individual products to their cart, with this module can you also have an 'add all to cart' button so it also works like a product kit?
Thanks

Comments

larowlan’s picture

When the user clicks any of the cart buttons (on any row) any products with a quantity other than zero (regardless of the button clicked) are added to the cart.
There is another issue in the uc_subproduct queue that includes code to theme the table with one button so it is clear that all products are added when the button is pressed.

jdln’s picture

Hi larowlan
Is it possible to have the default quantity as 1 not 0?

larowlan’s picture

You need an implementation of hook_form_alter to do this.
So either create a custom module or add it to an existing custom one.
If you need help building a module, you can use the module_builder module (http://drupal.org/project/module_builder) to get you started.
Just add this code, replacing MYMODULE with the machine name of your module.

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'uc_subproduct_cart_table_form') {
    foreach(element_children($form['children']) as $nid) {
      $form['children'][$nid]['quantity']['#default_value'] = 1;
    }
  }
}
jdln’s picture

Works great. Thanks

If anyone else is struggling with this pm me and ill send you the module files.

giacinlui80’s picture

Hi jdln

I'm a newbie to drupal and I have the same problem of having the quantity field with the value default to 1 but I can not even create modules. Please Could you kindly pass the custom module you created?

Thanks

jdln’s picture

Hi giacinlui80
What are you struggling with? My recollections a little hazy but I think the module builder worked for me. Its not hard, ive never made a custom module before.