I posted this question on the Entity Registration Issue Queue but I think its more suitable here since I haven't gotten a response in a long time. Below is the original question. I feel that others must of ran into this issue but I just looked through the entire Issue Queue and never saw anything about it which makes me feel that people just don't care about this or they have theirs set up differently then me.

Original Question:

I am using Entity Registration with Commerce Registration to build a site to signup for Courses and Events. In my case, it should be possible for someone to signup and purchase more than one course at a time. Though in order for that to happen you would add your two entities to the shopping cart, then you would be presented with 2 forms to fill out, same fields since they are both using the Course Registration Type, but still two forms since you have two entities in your cart. This doesn't seem like the biggest of problems until you have people purchases 5 classes at a time....

So, I am curious as to if the entities are referencing the same Registration Type, is it at all possible to show only 1 form and have that form work for all entities, updating their slot inventory too? My idea is if you add 5 Courses and 5 Events to your cart, you are present with only 1 Course Type Registration form and 1 Event Type Registration form.

If this is not possible, is there a way to include a "The information is the same in the other forms" checkbox that pre-populates the other registration form fieldsets with the same values the user put into the first? Similar to a copying address information to billing, but in a more wildcard fashion instead of listing out each individual field separately in the jquery.

http://drupal.org/node/1993616

CommentFileSizeAuthor
#11 commerce_registration_multistep_js.zip6.03 KBouissla
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

TravisJohnston’s picture

BUMP still in a huge need for this. I'm about to make a "Same for the other forms" button to copy the value to each, but I am really not looking forward to that solution. I seriously can not be the only person that experienced this.

cperisho’s picture

I am having almost the exact same issue come up. I have a situation where I may have a single person signing up several people for several different events- and we collect a lot of information on each person- like 10 or more fields.

One solution would be a "use the same on the rest of the forms" check box (worded better than that I hope). I think this could be achieved with some clever java script and maybe a special form element?

Another conundrum which you don't seem to have is returning customers. Say Bob signs his son Johnny up for soccer camp and his daughter Susy up for volleyball camp and next year he comes back to do it again- shouldn't the form say "should I use Johnny or Susy's information from last year?" and have it auto fill?

I am just learning about hooks and I'm not a Drupal or PHP master (or even a talented novice) but I'd be willing to work on this problem and/or pay someone to if you are interested in going in together on getting this to work.

A feature request might be in order- don't know if you can put bounties on such a thing. If someone gave me some clues on how I might fix it myself I'd be willing to hack away at it.

TravisJohnston’s picture

Hello cperisho,

I still haven't found a proper solution for this. I am also using field dependency on the registration forms and it breaks for all forms except for the first one... which also really sucks.

This week I am going to write up the jQuery to handle a "Same values on the rest of the forms" check box. If you google "jQuery same as billing address" you will see the code you need and its pretty self explanatory on what elements you need to change. Though the only thing that sucks is that the forms do not render with a decent target element to work with so I have to figure that out too.

As far as repeat users, mainly the browser will take care of that. It would be interesting though if you could program in a pattern collection that takes not of what an authenticated user does during registration, and offers suggestions based on previous actions. Thats way beyond this ticket though.

laughnan’s picture

Subscribing

TravisJohnston’s picture

So below is the jQuery I am using to copy over the input on the first registration form. Note there are probably better ways of doing so but using things like clone() don't seem to do more good than harm.

Also I have only been able to get this to work for text inputs and select drop downs. Can't seem to figure out what I need to use to transfer over radio button toggles.

// First we need to give the forms some classes we can actually work with.
$("#commerce-checkout-form-registration .registration_information fieldset").addClass("registration-form");
$("#commerce-checkout-form-registration .registration_information fieldset:first").removeClass("registration-form").addClass("registration-form-first");

// Now I add in the check box to use, doing this hear so I can specify that I want it to only show on the first form
$('<div><label for="sameaddress">Use Same Information on additional Registration forms (If applicable)</label><input type="checkbox" name="sameaddress" id="sameaddress" /></div>').insertAfter('.registration_information fieldset:first .field-name-field-how-did-you-hear-about-thi');

// Now lets copy everything to other forms
$('#sameaddress').click(function(){
	if($('#sameaddress').attr('checked')){
		$('#commerce-checkout-form-registration .registration-form .field-name-field-student-id input').val($('#commerce-checkout-form-registration .registration-form-first .field-name-field-student-id input').val());
		$('#commerce-checkout-form-registration .registration-form .field-name-field-first-name input').val($('#commerce-checkout-form-registration .registration-form-first .field-name-field-first-name input').val());

		// Copy each line as shown above for each of your text inputs, replacing the parent .field-name-field value for each.

		// For the select boxes see below
		var prefix = $('#commerce-checkout-form-registration .registration-form-first .field-name-field-prefix option:selected').val();
				   $('#commerce-checkout-form-registration .registration-form .field-name-field-prefix option[value=' + prefix + ']').attr('selected','selected');
		var jobtype = $('#commerce-checkout-form-registration .registration-form-first .field-name-field-job-type option:selected').val();
			              $('#commerce-checkout-form-registration .registration-form .field-name-field-job-type option[value=' + jobtype + ']').attr('selected','selected');	

	} else { 
			
		//Clear on uncheck

		$('#commerce-checkout-form-registration .registration-form .field-name-field-student-id input').val("");
		$('#commerce-checkout-form-registration .registration-form .field-name-field-first-name input').val("");
		$('#commerce-checkout-form-registration .registration-form .field-name-field-prefix option[value=Nothing]').attr('selected','selected');
		$('#commerce-checkout-form-registration .registration-form .field-name-field-job-type option[value=Nothing]').attr('selected','selected');
	};
	
});

bjaxelsen’s picture

I have the same problem, but slightly more complicated. We offer event registration for sport competitions. Here you might enter multiple persons (yourself and friends/colleagues) and you might register for more than one event at a time. So if you just add a checkbox ("Same Information on additional Registration") at the end of the first registration, the system will not know how to handle multiple persons.

I suggest a slightly different approach (similar to how eventbrite.com works): "Copy registrant information from" with the previously entered data as options.

I will be happy to code it, but is this the best appoach? Or cold we make it even more usable?

TravisJohnston’s picture

It would be most ideal if you had the ability to fill in 1 form per product. So if I had 10 people going to the same event, and I'm the assistant filling in the forms, it would be great if I could just fill in one form and perhaps have a section where you could just list off the other 9 people with only a Name and Email Address, with the option to provide further details for them if needed.

Breakerandi’s picture

Please continue posting your workarounds, because i have the same problem and i need this function urgently but i have no idea about coding and workarounds... Thank you!

ouissla’s picture

I am working on a registration process where people can register for multiple events, for themselves and potentially for other people, which I think is quite a common scenario for an event website.
At the moment, register for 10 people, and you get 10 forms to fill, one under the other which is not really user friendly.
What I am trying to achieve is splitting the Registration checkout pane into a "multistep form". So the first page would be the first registration form, then you click next and you are presented with the registration form for the second registrant. At this point there could be a dropdown list for you to re-use details you used in previous forms.
If you know how to do that or if you think this would not work, please comment!
Thanks.

Breakerandi’s picture

Sounds good!

ouissla’s picture

The process I described earlier seems quite complicated to implement and as I can't spend too much time and my client expectations are actually not that high, I decided to use an other, easier option.
I have written a custom module that that alters registration pane form, wrap the different registration forms in divs and attach a javascript file. The javascript file creates a navigation bar based on the tickets in the cart, which allow to show/hide the different forms which make the use of this tab easier.
Here is what the pane looks like: http://tinypic.com/r/2lw6e02/8

- This module doesn't implement an option to re-use the data of a previously filled form. (Maybe a dropdown list with option based on the nav link could be implemented, so would say that you want to re-use the values of "ticket 2" for example, and then a javascript function does the rest)
- If you have a lot of registration then the nav goes on multiple lines. Still usable but not great.

Here is the code, it is not perfect but this can be a starting point if you like the idea. Note that I use the IFE module to handles inline error messages which is useful I think, and I updated the registration pane setup not to use a global fieldset.

[EDIT]I just attached a zip containing my files instead of pasting all the code here as this is not the best solution.[/EDIT]

Hope that helps

TravisJohnston’s picture

Something to think about though is the menu size. When a user adds 10 event registrations in their cart, they already have the checkout progression menu at the top (or at least I do), but then if there are now 10 more links up top... that will get ugly.

Separating them onto different pages is still not really a solution. IMO it actually makes the registration process for the user longer since they are filling in a form, pressing next, loading the next form, filling it in, etc. versus them all on the same page.

Some key functional points from what I am thinking is needed.

  • Each registration form needs to be identified. So 2 products in your cart, 5 registrants each, the forms are #id with the registration-form-productname so you can properly target and group them.
  • With the ability to identify the forms, the system should group "like" forms together into 1 entity. So you fill in 1 form per product on the same page (or in this case it would be OK to have each product form on separate pages like your custom module.
  • The form will then have the ability to list multiple fieldsets, which include Email, First Name, Middle Initial, Last Name
  • If it is required that the user needs to input different information for each registration, an option is available to separate the forms out to allow this (or maybe a more ideal solution)
ouissla’s picture

You're right. My custom module is very limited. I realized that after working a bit more on it. Your solution is interesting though.

cmonkedo’s picture

I am having a similar problem where I have 1 registrant signing up for multiple events and would like to carry forward the field data to subsequent registrations. I have very little experience with php coding for drupal, but have the patience to troubleshoot so @TravisJohnston in #5 you list the js, but how do you implement that into the module?

Thanks

TravisJohnston’s picture

I didn't implement it into the module per-say, just added that to my themes JS file, replacing the field names and form id's where needed.

cmonkedo’s picture

Thank you for your help, I have added the js file to my js folder and it is being added to my head profile section, I have modified the .field-name- entries to correspond to my fields but it is not creating a new class in the html and it is not adding the checkbox. Im not sure what you are referring to above when you state replacing the form id's. Is this in the js or elsewhere?

TravisJohnston’s picture

Shouldn't have said ID's, but just that you may need to change the classes if your setup is slightly different. The checkbox is currently setup, in my code, to show after the field .field-name-field-how-did-you-hear-about-thi, replace this with the last field you have in your first registration form. This could probably be handled better by adding a .last class or something beforehand so you don't have to be so specific with what field it falls after.

MohamedAli’s picture

I been to a similar issue like the original question, and nothing worked as I actually wanted.. so I found that the best solution is just to disable the 'Registration Information' pane from checkout settings, and create my own pane which contain a normal form (with registration info fields) and in that form submit you can programmatically create multiple new registration entities referencing the order and each registration entity referencing each line item in the cart. and don't forget to check if the order already has registrations (in the case of user going back in the checkout process with back button) and update the registrations in this case not to create new ones.

I really like to hear other solutions for this, but this could help whoever came to this thread later..

Example how to create new checkout panes

TravisJohnston’s picture

Hi MohamedAli,

Do you have a working example of what you did? I don't understand how this differs from just having the standard registration pane and the multiple forms - seems like you are doing the same, just on a custom pane.

MohamedAli’s picture

The standard registration pane will have multiple registration forms if you add more than one product/event to the cart/order.. but in my custom pane I have just one form however the number of product is.. and in that form submit I check how many event/product attached to the order and I create a new registration entity for each product/event.
In the this example I assumed that you have two fields in the registration (first name and last name).. this code is not perfect, but it works..

<?php
/**
 * Implements hook_commerce_checkout_pane_info()
 */
function YOUR_MODULE_commerce_checkout_pane_info() {
  $panes = array();
  // Custom checkout pane.
  $panes['YOUR_PANE'] = array(
    'title' => t('Your Registration'),
    'page' => 'checkout',
    'weight' => 11,
    'base' => 'YOUR_MODULE_pane',
    'fieldset' => TRUE,
  );
  return $panes;
}
 
/**
 * Implements base_settings_form().
 */
function YOUR_MODULE_pane_settings_form($checkout_pane) {
  $form = array();
  return $form;
}

/**
 * Implements base_checkout_form()
 */
function YOUR_MODULE_pane_checkout_form($form, $form_state, $checkout_pane, $order) {
  global $user;
  $order_id = $order->order_id;
  // Check if there is existing registraion for th order.
  $query = db_select('registration', 'reg');
  $query->join('field_data_field_registration_last_name', 'lname', 'reg.registration_id = lname.entity_id');
  $query->join('field_data_field_registration_first_name', 'fname', 'reg.registration_id = fname.entity_id');
  $query
    ->condition('reg.order_id', $order_id, '=')
    ->fields('fname', array('field_registration_first_name_value'))
    ->fields('lname', array('field_registration_last_name_value'))
    ->fields('reg', array('anon_mail'));
  $result = $query->execute()->fetchAll();

  $checkout_form['description'] = array(
    '#type' => 'item',
    '#title' => t('Please fill your registration information'),
  );

  $checkout_form['mail'] = array(
    '#type' => 'textfield',
    '#title' => t('Email'),
    '#required' => TRUE,
    '#disabled' => (isset($user->mail) ? TRUE : FALSE),
    '#element_validate' => array('YOU_MODULE_email_validate'),
    '#default_value' => (isset($user->mail) ? $user->mail : $result[0]->anon_mail),
  );
  
  $checkout_form['first_name'] = array(
    '#type' => 'textfield',
    '#title' => t('First name'),
    '#required' => TRUE,
    '#default_value' => $result[0]->field_registration_first_name_value,
  );
  $checkout_form['last_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Last name'),
    '#required' => TRUE,
    '#default_value' => $result[0]->field_registration_last_name_value,
  );
 
  return $checkout_form;
}

/*
* Email validation.
*/
function YOUR_MODULE_email_validate($element, &$form_state, $form) {
  $value = $element['#value'];
  if (!valid_email_address($value)) {
    form_error($element, t('Please enter a valid email address.'));
  }
}

/**
 * The new registration checkout pane form submit callback.
 */
function YOUR_MODULE_pane_checkout_form_submit($form, &$form_state, $checkout_pane, $order) {
  global $user;
  $uid = null;
  if($user){
    $uid = $user -> uid;
  }
  $order_id = $order->order_id;
    
  $mail = $form_state['values']['YOUR_MODULE']['mail'];
  $registration_array = array();
  $registration_array['first_name']['und'][0]['value'] = $form_state['values']['YOUR_MODULE']['first_name'];
  $registration_array['last_name']['und'][0]['value'] = $form_state['values']['YOUR_MODULE']['last_name'];

  foreach (entity_metadata_wrapper('commerce_order', $order)->commerce_line_items as $delta => $line_item_wrapper) { 
    if (in_array($line_item_wrapper->type->value(), commerce_product_line_item_types())) {
      $product_id = $line_item_wrapper->commerce_product->raw();
      
      $query = db_select('registration', 'reg');
      $query
        ->condition('reg.order_id', $order_id, '=')
        ->condition('reg.entity_id', $product_id, '=')
        ->fields('reg', array('registration_id', 'entity_id'));
      $result = $query->execute()->fetchAll();
      // Check if it will be new registration or will update old one.
      if (empty($result)) {
        $registration = entity_create('registration', array(
          'user_uid' => $uid,
          'author_uid' => $uid,
          'type' => 'event_registration',
          'entity_type' => 'commerce_product',
          'entity_id' => $product_id,
          'count' => 1,
          'state' => 'pending',
          'anon_mail' => $mail,
          'order_id' => $order_id,
          'field_registration_first_name' => $registration_array['first_name'],
          'field_registration_last_name' => $registration_array['last_name'],
        ));
        $registration->save();
      }
      else {
        foreach ($result as $key => $value) {
          $registration = entity_load_single('registration', $value->registration_id);
          $registration->field_registration_first_name = $registration_array['first_name'];
          $registration->field_registration_last_name = $registration_array['last_name'];
          $registration->save();
        }
      }
    }
  }
}
?>
TravisJohnston’s picture

Thanks MohamedAli,

This looks like it's a great step in a new direction - though will get messy with many form fields and if you have multiple registration form types (I have 6 for instance). I'm not sure how the registration form is structure in the db, but if it's an array, hopefully you could call that, and have it print the array for which ever form type is needed, which would then output all the fields, versus individually calling them.

MohamedAli’s picture

@TravisJohnston

You can also use drupal_get_form to do that, my code was just simple example, the final result of using custom pane can be achieved with several ways depends on your case.

TravisJohnston’s picture

Awesome, Thanks MohamedAli,

I will play around with this when I get a chance to see if it works for me.

TravisJohnston’s picture

I finally got this working!!! Took a long time to figure out how to do this in a way that saved the data properly so it works with core commerce_registration.

Here is the code you will need. It does the following:

  • Alters the regular Cart page to include 2 new buttons to proceed (Register Individual, Register Group)
  • Adds classes to the cart form page and to the registration form page. I use these to style the page differently and I couldn't properly unset the regular continue to checkout button on the Cart page so I just hide it if the cart contains registrations. This is based on the Product Type for me (in this case "course), so for you that may change that to work for you. I did this because I sell non-registration products as well so it doesn't make sense to edit the cart.
  • Originally sets the anon_mail to required, but we change that when we deconstruct our form so we ignore validation errors.
  • Double checks to make sure the user isn't signing themselves up for multiple of the same event/registration product.
  • On submit we validate and rebuild the hidden forms with values from the displayed form.

Pros to this approach:

  • Use the core functionality of commerce_registration, versus creating our own checkout page/pane. Tried this and its difficult to match what commerce_registration does for validation and submission.
  • Do not need to specify each field manually. Only need to set the anon_mail separately.
  • Works with conditional fields and conditional requirements. I use a single Master Form registration type that changes based on a taxonomy term.

my_custom_registration.module

function my_custom_registration_form_commerce_checkout_form_registration_alter(&$form, &$form_state, $form_id) {
	global $user;
	$order = commerce_cart_order_load($user->uid);
	$order_id = $order->order_id;
	$who = "";
	if(isset($_SESSION['my_custom_registration_type']) && $_SESSION['my_custom_registration_type']['order_id'] == $order_id){
		$who = $_SESSION['my_custom_registration_type']['value'];
	}
	switch($who) {
		case 'self':
			$productSkus = array();		
			foreach ($form['registration_information']['register_entities'] as $name => $data) {
				foreach($form['registration_information'][$name] as $subname => $subdata) {
					$form['registration_information'][$name][$subname]['anon_mail']['#required'] = TRUE;			
					list($regname, $sku) = explode("-", $form['registration_information'][$name][$subname]['#parents'][1], 2);
					$productSkus[] = $sku; 
				}
			}
			if (arrayContainsDuplicate($productSkus) == TRUE) { // check to see if its the same product added more than once
				drupal_set_message('You can not register <strong>yourself</strong> for the same event more than once. Please go back and choose another option or go back and select 		<strong>Register Group</strong> and register other people as well as you.', 'error');
			}
			$countForm = 0; // count forms so we only alter the first, then hide all others
			foreach ($form['registration_information'] as $name => $data) {
				if(!empty($form['registration_information'][$name])){
					foreach($form['registration_information'][$name] as $subname => $subdata) {
						if(isset($form['registration_information'][$name][$subname]['#type']) && $countForm < 1){
							$countForm++;					
							$form['registration_information'][$name][$subname]['#title'] = t('Registration Form');
							$form['registration_information'][$name][$subname]['#prefix'] = '<div class="registration_information form-wrapper" id="edit-registration-information">';
							$form['registration_information'][$name][$subname]['#suffix'] = '</div>';
						} elseif ($countForm >= 1){
							foreach ($form['registration_information'][$name][$subname] as $k => $v) {
								if (strpos($k, 'field_') === 0) {
									$form['registration_information'][$name][$subname][$k]['#access'] = FALSE;
								}
									$form['registration_information'][$name][$subname]['anon_mail']['#access'] = FALSE;
									$form['registration_information'][$name][$subname]['anon_mail']['#required'] = FALSE;
							}

							$form['registration_information'][$name][$subname]['#prefix'] = '<div style="display:none;">';
							$form['registration_information'][$name][$subname]['#suffix'] = '</div>';
						}			
					}
				}
			}
			// Need to assign a new validation handler here, and first,  so we can work with our saved values
			array_unshift($form['buttons']['continue']['#validate'],'one_form_validate');
			$form['#attributes']['class'][] = 'solo';
		break;
		case 'others':
			$form['#attributes']['class'][] = 'multiple';
		break;	
	}
}

// Alter Buttons on Cart form
function my_module_registration_form_alter(&$form, &$form_state, $form_id) {
  global $user;
  switch($form_id) {
    case "views_form_commerce_cart_form_default":
      $order = commerce_cart_order_load($user->uid);
      $order_id = $order->order_id;
      $productTypes = array();
      $line_items_array = $order->commerce_line_items;
      $line_item_ids = array();
      foreach($line_items_array['und'] as $line_items){
			$line_item_ids[] =	$line_items['line_item_id'];
      }
/*
this may be different for you and you may want to look for a quantity instead. I split my items up so there is no quantity great than 1, I need them all on separate line items. So you will want to most likely compare the $line_items['quantity'] > 1
*/
      if(count($line_item_ids) > 1){
        $line_items_wrapper = commerce_line_item_load_multiple($line_item_ids);
        foreach($line_items_wrapper as $line_items_data) {
          $productID = $line_items_data->commerce_product['und'][0]['product_id'];
          $product = commerce_product_load($productID);
	  $type = $product->type;
	  if($type == "course") { // this is the product type. for me all registration products are type "course"
	    $productTypes[] = "course";		
	  }
        }
        if (in_array("course",$productTypes)) {
          $form['actions']['continue_self'] = array(
	     '#type' => 'submit',
	     '#value' => t('Register Individual'),
	     '#submit' => array('continue_self_submit'),
          );
          $form['actions']['continue_others'] = array(
	     '#type' => 'submit',
	     '#value' => t('Register Group'),
	     '#submit' => array('continue_others_submit'),
	     '#suffix' => '<span><em>**<strong>Register Group</strong> Will require you to fill out a separate form for each person for each event.</em></span>',			
          );
          $form['actions']['continue_self']['#attributes']['class'][] = 'self';
          $form['actions']['continue_others']['#attributes']['class'][] = 'others';
          $form['#attributes']['class'][] = 'contains-registrations';
       }
     }
   break;
  }
}

// redirect cart to special self checkout process
function continue_self_submit(&$form, &$form_state){
  global $user;
  $order = commerce_cart_order_load($user->uid);
  $order_id = $order->order_id;
  $_SESSION['my_module_registration_type'] = array();
  $_SESSION['my_module_registration_type']['order_id'] = $order_id;
  $_SESSION['my_module_registration_type']['value'] = 'self';
  drupal_goto("/checkout/" .$order_id);
}

// redirect cart to special others checkout process
function continue_others_submit(&$form, &$form_state){
  global $user;
  $order = commerce_cart_order_load($user->uid);
  $order_id = $order->order_id;
  $_SESSION['my_module_registration_type'] = array();
  $_SESSION['my_module_registration_type']['order_id'] = $order_id;
  $_SESSION['my_module_registration_type']['value'] = 'others';
  drupal_goto("/checkout/" .$order_id);
}

// Helper function to check a given array for duplicates
function arrayContainsDuplicate($array) {  
  return count($array) != count(array_unique($array));    
}

// Including our own validation and set the other forms data
function one_form_validate($form, &$form_state) {
  global $user;
  $countForm = 0;
  $fieldsData = array();
  foreach ($form_state['values']['registration_information'] as $name => $data) {
    foreach($form_state['values']['registration_information'][$name] as $subname => $subdata) {	
      if($countForm < 1){
        foreach ($form_state['values']['registration_information'][$name][$subname] as $k => $v) {
          if (!empty($v['und'])) {
            if (strpos($k, 'field_') === 0) {
              $fieldsData[$k] = $v;
            }
          }
        }
        $fieldsData['anon_mail'] = $form_state['values']['registration_information'][$name][$subname]['anon_mail'];
      } elseif ($countForm >= 1){
	foreach($fieldsData as $key => $value){
	  $form_state['values']['registration_information'][$name][$subname][$key] = $value;
	  }
      }
      $countForm++;		
    }
  }
}
TravisJohnston’s picture

Status: Active » Fixed
TravisJohnston’s picture

Status: Fixed » Closed (fixed)
blacklabel_tom’s picture

Status: Closed (fixed) » Needs work

Hi,

I'm going to leave this one open to a patch if someone wanted to create one against dev. It also helps anyone else looking for a solution to find this issue.

Cheers

Tom

TravisJohnston’s picture

OK thanks!
The only thing I see missing is to include our own check to look for an existing registration under the user or mail as the error message that appears by default from commerce_registration just says:
"The email address entered is already registered for this item." but you are not sure which item is it referring to so you don't know which one to remove from your cart.

droddis’s picture

Hi Travis,

This looks to be exactly what I'm looking for to solve a nagging issue with a non-profit who wants to have people register for multiple courses but the current process means that you need to enter data for each course, for each user.

I've copied the code and created the module. Can you help guide me with where I need to modify the .module code to ensure it's applied to my registration type? Currently the machine name is set to "course"

Thanks in advance, I know this should be simple but I always struggle to decipher the pure code!

Dave

TravisJohnston’s picture

Sure,

So "course" refers to the product type that I have registrations attached to. I specify that since I have other product types that are not tied to registrations and I don't want to modify the cart buttons if there are no registration products. (commerce-registration has a method to handle this but I didn't use it). So change this to the machine name of your product type that is used.

The other thing that I noted in the module was that I separate everything into separate line items first, so there is never a quantity over 1. This may be different for you so will want to modify that conditional statement to look at a $quantity > 1 instead and the number of line items, since you could have someone signing 2 people up for 2 different things.

Now what I have not tested though is how this works if you have multiple registration types. I found it easiest to use a single registration type, which I call Master Form. I put all my fields in this. Then I use Conditional Fields and based on the category of the product the registration is attached to, I change out which fields should be shown. In this module, I do not specify the registration type because of this.

So because of that I am not honestly sure if there will be an issue, but I suspect there would since the way this module works is it hides all the other forms except for the first form. So if each hidden form was a different registration type, then you would not be able to show and fill the proper fields.

For you, do you have multiple registration types? Or just one?

** Also to note, where you see "my_custom_registration_type", that is only the name of the session variable I am setting and is not specific to any actual registration type.

droddis’s picture

Hey Travis,

I ended up switching gears a bit, a common occurrence for me it seems when working in the left field of my Drupal builds.

I have a client who offers weekend long courses, with multiple sub sessions that form the actual product. We're trying to implement a registration process that allows individuals to register for 1 or more sub sessions. unfortunatly adding each sub session as a unique product means that the registration form wants to collect their information as many times as there are sub sessions booked. (Register for 3 courses, add in your information 3 times in the registration form). All Anon users FYI

What I've ended up doing is adding an option set with pricing attributes to the product, where they can choose 1 or more sub sessions (options), that add their cost to the total cost of the "product"

It sucks because I can't limit the number of total options sold (or number of registrations for each class/option) but it does allow me to create a system where I can complete registration information once, and have it applied to multiple courses.

I couldn't get the custom module to work but I'm also concerned I'm mis-interpreting the use case you built it for.

We will have multiple registration types for this client, so it may well be this is a dead end for me.

TravisJohnston’s picture

Yeah for me I only have one registration type, it would work if the types shared similar machine name fields though. But if there were additional required fields on the other types, then you would have trouble. Though there still may be a way to extend what I did to solve that.

For your product options, you could set up validation on the add to cart form to make sure they only choose a certain limit of options.