function address() { switch ($_SERVER['REQUEST_METHOD']) { case 'GET': $r_data = get_consignee_list($_SESSION['user_id']); return $r_data; break; case 'DELETE': $consignee_id = intval($_GET['id']); if (drop_consignee($consignee_id)) { $r_data = 'Delete Address Success!'; } else { $r_data = 'Delete Address Failed!'; } return $r_data; break; case 'POST': $address = array('user_id' => $_SESSION['user_id'], 'address_id' => intval($_POST['address_id']), 'country' => isset($_POST['country']) ? intval($_POST['country']) : 0, 'province' => isset($_POST['province']) ? intval($_POST['province']) : 0, 'city' => isset($_POST['city']) ? intval($_POST['city']) : 0, 'district' => isset($_POST['district']) ? intval($_POST['district']) : 0, 'address' => isset($_POST['address']) ? compile_str(trim($_POST['address'])) : '', 'consignee' => isset($_POST['consignee']) ? compile_str(trim($_POST['consignee'])) : '', 'email' => isset($_POST['email']) ? compile_str(trim($_POST['email'])) : '', 'tel' => isset($_POST['tel']) ? compile_str(make_semiangle(trim($_POST['tel']))) : '', 'mobile' => isset($_POST['mobile']) ? compile_str(make_semiangle(trim($_POST['mobile']))) : '', 'best_time' => isset($_POST['best_time']) ? compile_str(trim($_POST['best_time'])) : '', 'sign_building' => isset($_POST['sign_building']) ? compile_str(trim($_POST['sign_building'])) : '', 'zipcode' => isset($_POST['zipcode']) ? compile_str(make_semiangle(trim($_POST['zipcode']))) : ''); if (update_address($address)) { $r_data = 'Update Address Success!'; } else { $r_data = 'Update Address Failed!'; } return $r_data; break; default: return 'This API can not support ' . $_SERVER['REQUEST_METHOD'] . ' method'; break; } }
$order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0; if (cancel_order($order_id, $user_id)) { ecs_header("Location: user.php?act=order_list\n"); exit; } else { $err->show($_LANG['order_list_lnk'], 'user.php?act=order_list'); } } elseif ($action == 'address_list') { include_once ROOT_PATH . 'includes/lib_transaction.php'; include_once ROOT_PATH . 'languages/' . $_CFG['lang'] . '/shopping_flow.php'; $smarty->assign('lang', $_LANG); /* 取得国家列表、商店所在国家、商店所在国家的省列表 */ $smarty->assign('country_list', get_regions()); $smarty->assign('shop_province_list', get_regions(1, $_CFG['shop_country'])); /* 获得用户所有的收货人信息 */ $consignee_list = get_consignee_list($_SESSION['user_id']); if (count($consignee_list) < 5 && $_SESSION['user_id'] > 0) { /* 如果用户收货人信息的总数小于5 则增加一个新的收货人信息 */ $consignee_list[] = array('country' => $_CFG['shop_country'], 'email' => isset($_SESSION['email']) ? $_SESSION['email'] : ''); } $smarty->assign('consignee_list', $consignee_list); //取得国家列表,如果有收货人列表,取得省市区列表 foreach ($consignee_list as $region_id => $consignee) { $consignee['country'] = isset($consignee['country']) ? intval($consignee['country']) : 0; $consignee['province'] = isset($consignee['province']) ? intval($consignee['province']) : 0; $consignee['city'] = isset($consignee['city']) ? intval($consignee['city']) : 0; $province_list[$region_id] = get_regions(1, $consignee['country']); $city_list[$region_id] = get_regions(2, $consignee['province']); $district_list[$region_id] = get_regions(3, $consignee['city']); } /* 获取默认收货ID */
function action_address_list() { $user = $GLOBALS['user']; $_CFG = $GLOBALS['_CFG']; $_LANG = $GLOBALS['_LANG']; $smarty = $GLOBALS['smarty']; $db = $GLOBALS['db']; $ecs = $GLOBALS['ecs']; $user_id = $_SESSION['user_id']; include_once ROOT_PATH . 'includes/lib_transaction.php'; include_once ROOT_PATH . 'languages/' . $_CFG['lang'] . '/shopping_flow.php'; $smarty->assign('lang', $_LANG); /* 取得国家列表、商店所在国家、商店所在国家的省列表 */ $smarty->assign('country_list', get_regions()); $smarty->assign('shop_province_list', get_regions(1, $_CFG['shop_country'])); /* 获得用户所有的收货人信息 */ $consignee_list = get_consignee_list($_SESSION['user_id']); if (count($consignee_list) < 5 && $_SESSION['user_id'] > 0) { /* 如果用户收货人信息的总数小于5 则增加一个新的收货人信息 */ $consignee_list[] = array('country' => $_CFG['shop_country'], 'email' => isset($_SESSION['email']) && is_email($_SESSION['email']) ? $_SESSION['email'] : ''); } $smarty->assign('consignee_list', $consignee_list); // 取得国家列表,如果有收货人列表,取得省市区列表 foreach ($consignee_list as $region_id => $consignee) { $consignee['country'] = isset($consignee['country']) ? intval($consignee['country']) : 0; $consignee['province'] = isset($consignee['province']) ? intval($consignee['province']) : 0; $consignee['city'] = isset($consignee['city']) ? intval($consignee['city']) : 0; $province_list[$region_id] = get_regions(1, $consignee['country']); $city_list[$region_id] = get_regions(2, $consignee['province']); $district_list[$region_id] = get_regions(3, $consignee['city']); } /* 获取默认收货ID */ $address_id = $db->getOne("SELECT address_id FROM " . $ecs->table('users') . " WHERE user_id='{$user_id}'"); // 赋值于模板 $smarty->assign('real_goods_count', 1); $smarty->assign('shop_country', $_CFG['shop_country']); $smarty->assign('shop_province', get_regions(1, $_CFG['shop_country'])); $smarty->assign('province_list', $province_list); $smarty->assign('address', $address_id); $smarty->assign('city_list', $city_list); $smarty->assign('district_list', $district_list); $smarty->assign('currency_format', $_CFG['currency_format']); $smarty->assign('integral_scale', $_CFG['integral_scale']); $smarty->assign('name_of_region', array($_CFG['name_of_region_1'], $_CFG['name_of_region_2'], $_CFG['name_of_region_3'], $_CFG['name_of_region_4'])); $smarty->display('user_transaction.dwt'); }
public function address_list () { checkLogin(); include_once(RPC_ROOT . 'includes/lib_transaction_ec.php'); include_once('includes/lib_transaction.php'); $user_id = intval($_SESSION['user_id']); $consignee_list = get_consignee_list($user_id); $address_list = array(); //取得国家列表,如果有收货人列表,取得省市区列表 foreach ($consignee_list AS $key => $consignee) { $address_id = $consignee['address_id']; $consignee['country'] = isset($consignee['country']) ? intval($consignee['country']) : 0; $consignee['province'] = isset($consignee['province']) ? intval($consignee['province']) : 0; $consignee['city'] = isset($consignee['city']) ? intval($consignee['city']) : 0; $consignee['district'] = isset($consignee['district']) ? intval($consignee['district']) : 0; $country = get_region_name($consignee['country']); $province = get_region_name($consignee['province']); $city = get_region_name($consignee['city']); $district = get_region_name($consignee['district']); $address_list[$address_id]['address'] = $country.'-'.$province.'-'.$city.'-'.$district.'-'.$consignee['address']; $address_list[$address_id]['mobile'] = $consignee['mobile']; //$address_list[$address_id]['username'] = $_SESSION['user_name']; $address_list[$address_id]['username'] = $consignee['consignee']; } //print_r($address_list);exit; jsonExit($address_list); }
* 如果用户已经登录了则检查是否有默认的收货地址 * 如果没有登录则跳转到登录和注册页面 */ if (empty($_SESSION['direct_shopping']) && $_SESSION['user_id'] == 0) { /* 用户没有登录且没有选定匿名购物,转向到登录页面 */ hhs_header("Location: flows.php?step=login\n"); exit; } $consignee = get_consignee($_SESSION['user_id']); /* 检查收货人信息是否完整 */ if (!check_consignee_info($consignee, $flow_type)) { /* 如果不完整则转向到收货人信息填写界面 */ //hhs_header("Location: flows.php?step=consignee\n"); //exit; } $smarty->assign("address_num", count(get_consignee_list($_SESSION['user_id']))); /* 取得国家列表、商店所在国家、商店所在国家的省列表 */ $smarty->assign('country_list', get_regions()); $smarty->assign('shop_country', $_CFG['shop_country']); $smarty->assign('shop_province_list', get_regions(1, $_CFG['shop_country'])); $mobile_phone = $GLOBALS['db']->getOne("select mobile_phone from " . $GLOBALS['hhs']->table('users') . " where user_id=" . $_SESSION['user_id']); $smarty->assign('mobile_phone', $mobile_phone); //echo "<pre>"; //print_r($consignee);exit; /* 获得用户所有的收货人信息 */ if ($_SESSION['user_id'] > 0) { //$consignee_list = get_consignee_list($_SESSION['user_id']); /* $temp[0]=$consignee_list[0]; $consignee_list=$temp;*/ /*
$code = '1'; } else { $msg = rpcLang('user.php', 'edit_profile_failed'); $code = '1'; } } jsonExit("{\"status\":\"$msg\",\"code\":\"$code\"}"); }else if($act == 'address_list')//收货地址列表 { checkLogin(); include_once(ROOT_PATH . 'includes/lib_transaction.php'); include_once('includes/lib_transaction.php'); $user_id = intval($_SESSION['user_id']); $consignee_list = get_consignee_list($user_id); $address_list = array(); //取得国家列表,如果有收货人列表,取得省市区列表 foreach ($consignee_list AS $key => $consignee) { $address_id = $consignee['address_id']; $consignee['country'] = isset($consignee['country']) ? intval($consignee['country']) : 0; $consignee['province'] = isset($consignee['province']) ? intval($consignee['province']) : 0; $consignee['city'] = isset($consignee['city']) ? intval($consignee['city']) : 0; $consignee['district'] = isset($consignee['district']) ? intval($consignee['district']) : 0; $country = get_region_name($consignee['country']); $province = get_region_name($consignee['province']); $city = get_region_name($consignee['city']); $district = get_region_name($consignee['district']); $address_list[$address_id]['address'] = $country.'-'.$province.'-'.$city.'-'.$district.'-'.$consignee['address']; $address_list[$address_id]['mobile'] = $consignee['mobile'];