ecshop在前台用户中心我的订单里面,可以查询某个时间段的订单。如下
一、修改前台静态页面
ecshop\themes\default\user_transaction.dwt 第178行,我的订单部分开始更改,增加如下
{$lang.label_order}
二、配置语言文件
languages\zh_cn\user.php
增加
$_LANG['start_date'] = ‘开始日期’;
$_LANG['end_date'] = ‘结束日期’;
$_LANG['access_query'] = ‘查询’;
$_LANG['profile_js']['start_time_check'] = ‘请您输入起始时间’;
三、修改提示语言,当没有输入起始时间的时候需要提示
ecshop\js\user.js
增加
//搜索订单时间提示
function checkstartDate()
{
var start = document.getElementByIdx_x(“start_date”).value;
var end = document.getElementByIdx_x(“end_date”).value;
if ( ! start)
{
alert(start_time_check);
return false;
}
return true;
}
三、修改执行文件
ecshop\user.php
大约786行
elseif ($action == ‘order_list’)
这个做如下更改,我直接放我更改好的代码了,O(∩_∩)O~,不足之处请大家指正。
elseif ($action == ‘order_list’)
{
$start_time = strtotime($_POST['start_date']) ? strtotime($_POST['start_date']) : $_GET['start_date'];
$end_time = strtotime($_POST['end_date']) ? strtotime($_POST['end_date']) : $_GET['end_date'];
include_once(ROOT_PATH . ‘includes/lib_transaction.php’);
$page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
if($start_time && $end_time){
$where = ” AND add_time BETWEEN ‘”.$start_time.”‘ AND ‘”.$end_time.”‘”;
$page_ary = array(‘act’ => $action, ‘start_date’ =>$start_time, ‘end_date’ => $end_time);
}elseif($start_time){
$end_time = time();
$where = ” AND add_time BETWEEN ‘”.$start_time.”‘ AND ‘”.$end_time.”‘”;
$page_ary = array(‘act’ => $action, ‘start_date’ =>$start_time);
}else{
$where = ” “;
$page_ary = array(‘act’ => $action);
}
$record_count = $db->getOne(“SELECT COUNT(*) FROM ” .$ecs->table(‘order_info’). ” WHERE user_id = ‘$user_id’”.$where);
$pager = get_pager(‘user.php’, $page_ary, $record_count, $page);
$orders = get_user_orders($user_id, $pager['size'], $pager['start'], $start_time, $end_time);
$merge = get_user_merge($user_id);
if($start_time || $end_time){
if(!$end_time){
$end_time = time();
}
$smarty->assign(‘start_date’, date(‘Y-m-d’,$start_time));
$smarty->assign(‘end_date’, date(‘Y-m-d’,$end_time));
}
$smarty->assign(‘merge’, $merge);
$smarty->assign(‘pager’, $pager);
$smarty->assign(‘orders’, $orders);
$smarty->display(‘user_transaction.dwt’);
}
第三步,修改get_user_orders()
ecshop\includes\lib_transaction.php
function get_user_orders($user_id, $num = 10, $start = 0, $start_time, $end_time)
{
$arr = array();
if($start_time && $end_time){
$where = ” AND add_time BETWEEN ‘”.$start_time.”‘ AND ‘”.$end_time.”‘”;
}elseif($start_time){
$end_date = time();
$where = ” AND add_time BETWEEN ‘”.$start_time.”‘ AND ‘”.$end_date.”‘”;
}else{
$where = ” “;
}
$sql = “SELECT order_id, order_sn, order_status, shipping_status, pay_status, add_time, ” .
“(goods_amount + shipping_fee + insure_fee + pay_fee + pack_fee + card_fee + tax – discount) AS total_fee “.
” FROM ” .$GLOBALS['ecs']->table(‘order_info’) .
” WHERE user_id = ‘$user_id’”.$where.” ORDER BY add_time DESC”;
$res = $GLOBALS['db']->SelectLimit($sql, $num, $start);
案例:世罕泉