You are here

function commerce_order_account_pane_checkout_form_validate in Commerce Core 7

Account pane: validation callback.

File

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

Code

function commerce_order_account_pane_checkout_form_validate($form, &$form_state, $checkout_pane, $order) {
  if (!empty($form_state['values'][$checkout_pane['pane_id']])) {
    $pane_values = $form_state['values'][$checkout_pane['pane_id']];

    // If the e-mail address field was present on the form...
    if (!empty($pane_values['login']['mail'])) {

      // Display an error if an invalid e-mail address was given.
      if ($error = user_validate_mail($pane_values['login']['mail'])) {
        form_set_error($checkout_pane['pane_id'] . '][login][mail', $error);
        return FALSE;
      }
      if (variable_get('commerce_order_account_pane_mail_double_entry', FALSE)) {

        // Display an error if the two email addresses don't match.
        if ($pane_values['login']['mail'] != $pane_values['login']['mail_confirm']) {
          form_set_error($checkout_pane['pane_id'] . '][login][mail_confirm', t('The specified e-mail addresses do not match.'));
          return FALSE;
        }
      }
    }
  }
  return TRUE;
}