现在的位置: 首页 > 综合 > 正文

为ECSHOP 2.6.0 添加订单用户自动注册流程

2013年10月17日 ⁄ 综合 ⁄ 共 2917字 ⁄ 字号 评论关闭

Ecshop 2.6.0 用户下单时,只提供Email, 为该用户自动注册为站点用户,并关联订单.

修改得比较草,只为实现功能.

 

 flow.php 文件 大约 1280行左右.

 

注释部分为添加部分.

 

  1.     /*
  2.      * 检查用户是否已经登录
  3.      * 如果用户已经登录了则检查是否有默认的收货地址
  4.      * 如果没有登录则跳转到登录和注册页面
  5.      */
  6.     if (emptyempty($_SESSION['direct_shopping']) && $_SESSION['user_id'] == 0)
  7.     {
  8.         /* 用户没有登录且没有选定匿名购物,转向到登录页面 */
  9.         ecs_header("Location: flow.php?step=login/n");
  10.         exit;
  11.     }
  12.     /*******************************************************************
  13.      *      Add By Shelly 2008-10-6                                    *
  14.      *******************************************************************/
  15.     /* 
  16.      *自动登陆用户
  17.      * 如果已注册用户,取得用户 user_id
  18.      * 如果是自动注册用户  $isAutoRegistUser = true
  19.      */
  20.     $isAutoRegistUser = false;
  21.     if($_SESSION['user_id'] == 0){
  22.         include_once('includes/lib_passport.php');
  23.         if ((intval($_CFG['captcha']) & CAPTCHA_REGISTER) && gd_version() > 0)
  24.         {
  25.             if (emptyempty($_POST['captcha']))
  26.             {
  27.                 show_message($_LANG['invalid_captcha']);
  28.             }
  29.             /* 检查验证码 */
  30.             include_once('includes/cls_captcha.php');
  31.             $validator = new captcha();
  32.             if (!$validator->check_word($_POST['captcha']))
  33.             {
  34.                 show_message($_LANG['invalid_captcha']);
  35.             }
  36.         }
  37.         // 自动生成密码, 可用于用户邮件发送,或者用户重置密码部分 
  38.         $tmpPassword = substr(md5('passhash_'.trim($_SESSION['flow_consignee']['email'])), 4, 6);
  39.         $regRet =register(trim($_SESSION['flow_consignee']['email']), trim($tmpPassword), trim($_SESSION['flow_consignee']['email']));
  40.         if (!$regRet) {
  41.             // 用户自动注册不成功 这种可能性比较小
  42.             ecs_header("Location: flow.php?step=consignee/n");
  43.             exit;
  44.         }else{
  45.             $isAutoRegistUser = true;
  46.             $loginRet = $user->login(trim($_SESSION['flow_consignee']['email']), trim($tmpPassword));
  47.             if ($loginRet){
  48.                 update_user_info();  //更新用户信息
  49.                 recalculate_price(); // 重新计算购物车中的商品价格
  50.             }
  51.         }
  52.     }
  53.     /* 发送邮件给用户 */
  54.     /*        略              */
  55.     if ($_CFG['service_email'] != '')
  56.     {
  57.     /*
  58.     $tpl = get_mail_template('remind_of_new_order');
  59.     $smarty->assign('order', $order);
  60.     $smarty->assign('shop_name', $_CFG['shop_name']);
  61.     $smarty->assign('send_date', date($_CFG['time_format']));
  62.     $content = $smarty->fetch('str:' . $tpl['template_content']);
  63.     send_mail($_CFG['shop_name'], $_CFG['service_email'], $tpl['template_subject'], $content, $tpl['is_html']);
  64.         */
  65.     }
  66.     /*******************************************************************
  67.      *      Add By Shelly 2008-10-6                    *
  68.      *******************************************************************/
  69.     $consignee = get_consignee($_SESSION['user_id']);
  70.     /* 检查收货人信息是否完整 */
  71.     if (!check_consignee_info($consignee$flow_type))
  72.     {
  73.         /* 如果不完整则转向到收货人信息填写界面 */
  74.         ecs_header("Location: flow.php?step=consignee/n");
  75.         exit;
  76.     }

抱歉!评论已关闭.