I did it with below solution but I want to create a module for do this is future( If I will hav time :) )
first in my custom module add password field to checkout process
function yourmodule_form_alter(&$form, &$form_state, $form_id) {
if ($form['#form_id'] == 'commerce_checkout_form_checkout') {
global $user;
if($user->uid==0) {
$form['account']['login']['pass'] = array(
'#type' => 'password_confirm',
'#title' => t('Password'),
'#required' => TRUE,
'#size' => 30,
);
$form['buttons']['continue']['#submit'][]='_myfunction_user_register_incheckout_submit';
}
}
}
then save password in session with
function _myfunction_user_register_incheckout_submit($form,$form_state){
$s_name='pass-'.$form_state['values']['account']['login']['mail'];
// $pass=user_hash_password($form_state['values']['account']['login']['pass']);
// it's better hash it later , for more security
$pass=$form_state['values']['account']['login']['pass'];
_ym_session($s_name,$pass);
}
function _ym_session($key, $value = NULL) {
drupal_session_start();
static $storage;
if ($value) {
$storage[$key] = $value ;
$_SESSION['ym'][$key] = $value ; // I use 'lists' in case some other module uses 'type' in $_SESSION
}
else if (empty($storage[$key]) && isset($_SESSION['ym'][$key])) {
$storage[$key] = $_SESSION['ym'][$key]?$_SESSION['ym'][$key]:false;
}
return $storage[$key];
}
function _myfunction_user_register_incheckout($user_account){
$s_name='pass-'.$user_account->mail;
if(_ym_session($s_name)){
$pass=_ym_session($s_name);
user_save($user_account,array('pass'=>$pass));
// ym(user_load($user_account->uid),'message');
// ym(user_load($user_account->uid));
}
}
after it in commerce_checkout_new_account
rules in /admin/config/workflow/rules/reaction/manage/commerce_checkout_new_account
add a php action
in PHP CODE section add
_myfunction_user_register_incheckout($account_created);
save it then put it after Fetch entity by property
and before 'LOOP' and save rule,
Then test and enjoy it :D