ecshop用户中心我的订单里查询指定时间段订单

ecshop在前台用户中心我的订单里面,可以查询某个时间段的订单。如下
一、修改前台模板文件页面,打开themes\default\user_transaction.dwt 文件第179行,我的订单部分开始更改,增加修改如下
       <h5><span>{$lang.label_order}</span></h5>
将以上代码修改成如下代码
<script type='text/javascript' src='js/calendar.php?lang={$cfg_lang}'></script>
<link href='js/calendar/calendar.css' rel='stylesheet' type='text/css'/>
<h5><span>{$lang.label_order}</span></h5>
<script type='text/javascript'>
{foreach from=$lang.profile_js item=item key=key}
var {$key} = '{$item}';
{/foreach}
</script>
<div>
	<form action='user.php' method='post' name='checkDate'>
		<input type='hidden' name='act' value='order_list'/>
{$lang.start_date}
		<input name='start_date' id='start_date' value='{$start_date}' style='width:80px;'/>
{$lang.end_date}
		<input name='end_date' id='end_date' value='{$end_date}' style='width:80px;'/>
		<input type='submit' name='submit' value='{$lang.access_query}'/>
	</form>
</div>
二、增加语言文件代码,打开languages\zh_cn\user.php文件,增加如下代码
$_LANG['start_date'] = '开始日期';
$_LANG['end_date'] = '结束日期';
$_LANG['access_query'] = '查询';
$_LANG['profile_js']['start_time_check'] = '请您输入起始时间';
三、修改提示语言,当没有输入起始时间的时候需要提示,打开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;
}
四、修改执行文件,打开user.php文件,大约786行的找到 elseif ($action == 'order_list') 这个做如下更改,直接放我更改好的代码了,不足之处请大家指正。
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');
}
第五步,打开includes\lib_transaction.php文件,修改 get_user_orders()
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);

本文原创地址:https://www.ecshop.cx/article-393.html
版权所有 © 转载时必须以链接形式注明出处!

觉得本文对您有用,想收藏下来!方法很简单:请点击-〉
我们一直坚持白天工作、晚上熬夜更新资源,付出了巨大的精力和时间,其中的辛酸难以言述。

实时购买动态 ×

song636392925会员 在 2019-04-12 购买了 ECSHOP PayPal快速结帐 快捷支付一步结账 可直接银行卡和信用卡付款无需PayPal账号