You are here

function commerce_registration_commerce_registration_registration_settings_form_alter in Commerce Registration 7.3

Implements hook_commerce_registration_registration_settings_form_alter().

File

./commerce_registration.module, line 541
Commerce Registration module code.

Code

function commerce_registration_commerce_registration_registration_settings_form_alter(&$form, &$form_state, $settings) {
  $form['limit_registrations'] = array(
    '#type' => 'radios',
    '#title' => t('Limit registrations by number of'),
    '#options' => array(
      'slots' => t('slots per product'),
      'registrations' => t('registrations per product'),
    ),
    '#default_value' => isset($settings['limit_registrations']) ? $settings['limit_registrations'] : 'slots',
    '#required' => TRUE,
  );
  $form['registrations_per_product'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of unique registrations per product'),
    '#description' => t('The number of registrations that are required for a single product purchase. For example, a single product may require 5 registrations.'),
    '#default_value' => isset($settings['registrations_per_product']) ? $settings['registrations_per_product'] : 1,
    '#states' => array(
      'visible' => array(
        ':input[name*="limit_registrations"]' => array(
          'value' => 'registrations',
        ),
      ),
    ),
    '#required' => TRUE,
  );
  $form['slots_per_product'] = array(
    '#type' => 'textfield',
    '#title' => t('Number of slots per product'),
    '#description' => t('The number of registration slots that a single registration per product purchase will take. For example, a single product may fill 5 slots.'),
    '#default_value' => isset($settings['slots_per_product']) ? $settings['slots_per_product'] : 1,
    '#states' => array(
      'visible' => array(
        ':input[name*="limit_registrations"]' => array(
          'value' => 'slots',
        ),
      ),
    ),
    '#required' => TRUE,
  );
  $form['allow_user_slots_entry'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the user to select the number of slots'),
    '#description' => t('If checked, the user will be able to choose how many slots their registration will fill, up to the maximum amount configured.'),
    '#default_value' => isset($settings['allow_user_slots_entry']) ? $settings['allow_user_slots_entry'] : 0,
    '#states' => array(
      'visible' => array(
        ':input[name*="limit_registrations"]' => array(
          'value' => 'slots',
        ),
      ),
    ),
  );
  $form['user_slots_maximum'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum number of slots per registration'),
    '#description' => t('The maximum number of slots a user can select for their registration to fill. Enter 0 for no maximum.'),
    '#default_value' => isset($settings['user_slots_maximum']) ? $settings['user_slots_maximum'] : 1,
    '#states' => array(
      'visible' => array(
        ':input[name*="allow_user_slots_entry"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
}