You are here

function ccl_login_convert_order in Commerce Checkout Login 7.2

Login user and convert his/her anonymous order.

2 calls to ccl_login_convert_order()
commerce_checkout_login_account_form_submit in ./commerce_checkout_login.panes.inc
Account pane submit handler.
commerce_checkout_login_commerce_checkout_complete in ./commerce_checkout_login.module
Implements hook_commerce_checkout_complete().

File

./commerce_checkout_login.module, line 275
Adds a new checkout pane to allow users to login, create an account or checkout anonymously depending on site configuration.

Code

function ccl_login_convert_order($uid, $order) {
  global $user;

  // If the user was logged in during this request, make sure we are using the
  // full user object.
  if ($user->uid) {
    $user = user_load($user->uid);
  }
  else {

    // Load the validated user into the global $user variable.
    $user = user_load($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 order from anonymous to authenticated and clear out
  // our variable from the form state.
  if (empty($order->uid)) {
    ccl_order_convert($order, $user);
  }
}