You are here

function commerce_checkout_login_checkout_form_submit in Commerce Checkout Login 7

Submit callback: attempt a login of the user now.

1 string reference to 'commerce_checkout_login_checkout_form_submit'
commerce_checkout_login_form_commerce_checkout_form_alter in ./commerce_checkout_login.module
Implements hook_form_FORM_ID_alter().

File

./commerce_checkout_login.module, line 92
Adds an inline login form to the Account Information checkout pane.

Code

function commerce_checkout_login_checkout_form_submit($form, &$form_state) {
  global $user;
  if (!empty($form_state['commerce_checkout_login_uid'])) {

    // Load the specified user into the global $user variable.
    $user = user_load($form_state['commerce_checkout_login_uid']);

    // "Finalize" the login by triggering the appropriate system messages, IP
    // address and login timestamp logging, and user login hook.
    user_login_finalize();

    // Convert the current cart order to an authenticated cart for the current
    // user and clear out our variable from the form state.
    commerce_cart_order_convert($form_state['order'], $user);
    unset($form_state['commerce_checkout_login_uid']);
  }
}