You are here

function commerce_order_account_pane_checkout_form in Commerce Core 7

Account pane: form callback.

File

modules/order/includes/commerce_order.checkout_pane.inc, line 35
Checkout pane callback functions for the Order module.

Code

function commerce_order_account_pane_checkout_form($form, &$form_state, $checkout_pane, $order) {
  global $user;
  $pane_form = array();

  // If the user is logged in...
  if ($user->uid > 0) {

    // And the pane has been configured to display account information...
    if (variable_get('commerce_order_account_pane_auth_display', FALSE)) {

      // Note we're not using theme_username() to avoid linking out of checkout.
      $pane_form['username'] = array(
        '#type' => 'item',
        '#title' => t('Username'),
        '#markup' => check_plain($user->name),
      );
      $pane_form['mail'] = array(
        '#type' => 'item',
        '#title' => t('E-mail address'),
        '#markup' => check_plain($order->mail),
      );
    }
  }
  else {

    // Otherwise add an order e-mail address field to the form.
    $pane_form['login'] = array(
      '#type' => 'container',
      '#prefix' => '<div id="account-login-container">',
      '#suffix' => '</div>',
    );
    $pane_form['login']['mail'] = array(
      '#type' => 'textfield',
      '#title' => t('E-mail address'),
      '#default_value' => $order->mail,
      '#required' => TRUE,
      '#element_validate' => array(
        'commerce_order_mail_validate',
      ),
      '#attributes' => array(
        'autocomplete' => 'email',
      ),
    );
    if (variable_get('commerce_order_account_pane_mail_double_entry', FALSE)) {
      $pane_form['login']['mail_confirm'] = array(
        '#type' => 'textfield',
        '#title' => t('Confirm e-mail address'),
        '#description' => t('Provide your e-mail address in both fields.'),
        '#default_value' => $order->mail,
        '#required' => TRUE,
        '#element_validate' => array(
          'commerce_order_mail_validate',
        ),
      );
    }
  }
  return $pane_form;
}