ecshop仿淘宝用户订单列表
1,user.php
找到
$not_login_arr = array('login','act_login','register','act_register','act_edit_password','get_password','send_pwd_email','password', 'signin', 'add_tag', 'collect', 'return_to_cart', 'logout', 'email_list', 'validate_email', 'send_hash_mail', 'order_query', 'is_registered', 'check_email','clear_history','qpassword_name', 'get_passwd_question', 'check_answer');
加入用户删除订单功能
$not_login_arr = array('login','act_login','register','act_register','act_edit_password','get_password','send_pwd_email','password', 'signin', 'add_tag', 'collect', 'return_to_cart', 'logout', 'email_list', 'validate_email', 'send_hash_mail', 'order_query', 'is_registered', 'check_email','clear_history','qpassword_name', 'get_passwd_question', 'check_answer', 'delthis'); //删除指定订单 by neo
继续找到
/* 编辑使用余额支付的处理 */
在它的上面加入
/* 删除指定订单 by neo */ elseif ($action == 'delthis') { include_once(ROOT_PATH .'includes/cls_json.php'); include_once(ROOT_PATH .'includes/lib_transaction.php'); $json = new JSON(); $result = array('error' => 0, 'message' => '', 'content' => ''); $order_id = isset($_POST['order_id']) ? intval($_POST['order_id']) : 0; if ($order_id == 0) { $result['error'] = 1; $result['message'] = $_LANG['order_id_empty']; die($json->encode($result)); } if ($user_id == 0) { /* 用户没有登录 */ $result['error'] = 1; $result['message'] = $_LANG['login_please']; die($json->encode($result)); } /* 检查订单是否属于该用户 */ $order_user = $db->getOne("SELECT user_id FROM " .$ecs->table('order_info'). " WHERE order_id = '$order_id'"); if (empty($order_user)) { $result['error'] = 1; $result['message'] = $_LANG['order_exist']; die($json->encode($result)); } else { if ($order_user != $user_id) { $result['error'] = 1; $result['message'] = $_LANG['no_priv']; die($json->encode($result)); } } /* 删除订单 */ $sql = "delete i,g,a from " .$ecs->table('order_info'). " as i join " .$ecs->table('order_goods'). " as g on i.order_id = g.order_id join " .$ecs->table('order_action'). " as a on i.order_id = a.order_id where i.order_id = '$order_id'"; $message = $db->query($sql); if ($message === true) { $result['error'] = 0; $result['message'] = '删除成功'; die($json->encode($result)); } else { $result['error'] = 1; $result['message'] = $_LANG['order_exist']; die($json->encode($result)); } }
再找到
/* 查看订单列表 */ elseif ($action == 'order_list') { ... }
整个替换成
/* 查看订单列表 */ elseif ($action == 'order_list') { include_once(ROOT_PATH . 'includes/lib_transaction.php'); $page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1; $record_count = $db->getOne("SELECT COUNT(*) FROM " .$ecs->table('order_info'). " WHERE user_id = '$user_id'"); $pager = get_pager('user.php', array('act' => $action), $record_count, $page); $orders = get_user_orders($user_id, $pager['size'], $pager['start']); //把订单的详细内容查询出来 by neo if(is_array($orders) && count($orders) > 0) { $order_ids = ''; $new_orders = array(); foreach($orders as $val) { $order_ids .= $val['order_id'].','; } $order_ids = substr($order_ids,0,-1); $goods_info = array(); $sql = "SELECT o.*,g.goods_thumb FROM ".$ecs->table('order_goods')." o LEFT JOIN ".$ecs->table('goods')." g ON(o.goods_id=g.goods_id) WHERE order_id IN($order_ids)"; $result = $db->query($sql); while($row = $db->fetch_array($result)) { $goods_info[$row['order_id']][] = $row; } foreach($orders as $key=>$val) { $val['goods'] = $goods_info[$val['order_id']]; $val['goods_number'] = count($goods_info[$val['order_id']]); $new_orders[] = $val; } $orders = & $new_orders; } $sql = "SELECT order_id, order_status, shipping_status, pay_status " . " FROM " .$ecs->table('order_info'). " WHERE user_id = '$user_id'"; $res = $db->getall($sql); $unpayed = 0; //0 待付款 $received = 0; //1 待确认收货 $confirmed = 0; //1,2 待发货 $done = 0; foreach($res as $value) { if($value['pay_status'] == 0) { $unpayed = $unpayed+1;//待付款 } if($value['shipping_status'] == 1) { $received = $received+1;//待确认收货 } if($value['shipping_status'] == 2) { $done = $done+1;//交易成功 } if($value['order_status'] == 1 && $value['pay_status'] == 2) { $confirmed = $confirmed+1;//待发货 } } $smarty->assign('unpayed', $unpayed);//待付款 $smarty->assign('received', $received);//待确认收货 $smarty->assign('confirmed', $confirmed);//待发货 $smarty->assign('done', $done);//交易成功 $merge = get_user_merge($user_id); $smarty->assign('merge', $merge); $smarty->assign('pager', $pager); $smarty->assign('orders', $orders); $smarty->display('user_transaction.dwt'); }
2,includeslib_transaction.php
找到
function get_user_orders($user_id, $num = 10, $start = 0) { ... }
整个替换成
function get_user_orders($user_id, $num = 10, $start = 0) { /* 取得订单列表 */ $arr = array(); $sql = "SELECT order_id, order_sn, order_status, shipping_status, pay_status, add_time, shipping_fee, " . "(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' ORDER BY add_time DESC"; $res = $GLOBALS['db']->SelectLimit($sql, $num, $start); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['order_status'] == OS_UNCONFIRMED)//0 未确认 { $row['handler'] = '<span class="skin-orange"><a class="small-btn J_MakePoint button" href="user.php?act=order_detail&order_id=' .$row['order_id']. '">' .$GLOBALS['_LANG']['pay_money']. "</a></span><a href="user.php?act=cancel_order&order_id=" .$row['order_id']. "" onclick="if (!confirm('".$GLOBALS['_LANG']['confirm_cancel']."')) return false;">".$GLOBALS['_LANG']['cancel']."</a>"; } else if ($row['order_status'] == OS_SPLITED)//5 已确认 { /* 对配送状态的处理 */ if ($row['shipping_status'] == SS_SHIPPED)//1 已发货 { @$row['handler'] = "<span class="skin-blue"><a class="small-btn J_MakePoint button" href="user.php?act=affirm_received&order_id=" .$row['order_id']. "" onclick="if (!confirm('".$GLOBALS['_LANG']['confirm_received']."')) return false;">".$GLOBALS['_LANG']['received']."</a></span>"; } elseif ($row['shipping_status'] == SS_RECEIVED)//2 收货确认 { @$row['handler'] = ''; } else { if ($row['pay_status'] == PS_UNPAYED)//0 未付款 { @$row['handler'] = "<a href="user.php?act=order_detail&order_id=" .$row['order_id']. '">' .$GLOBALS['_LANG']['pay_money']. '</a>'; } else { @$row['handler'] = '<span class="skin-blue"><a class="small-btn J_MakePoint button" href="user.php?act=order_detail&order_id=' .$row['order_id']. '">' .$GLOBALS['_LANG']['ss'][SS_PREPARING]. "</a></span>"; } } } elseif($row['order_status'] == OS_CONFIRMED)//1 已确认 { if($row['pay_status'] == PS_PAYED)// 已付款 { $row['handler'] = '<span class="skin-blue"><a class="small-btn J_MakePoint button" href="user.php?act=order_detail&order_id=' .$row['order_id']. '">' .$GLOBALS['_LANG']['ss'][SS_PREPARING]. "</a></span>"; } else { $row['handler'] = '<span class="skin-orange"><a class="small-btn J_MakePoint button" href="user.php?act=order_detail&order_id=' .$row['order_id']. '">' .$GLOBALS['_LANG']['pay_money']. "</a></span>"; } } else { //$row['handler'] = $GLOBALS['_LANG']['os'][$row['order_status']]; $row['handler'] = '<a onclick="returnToCart(' .$row['order_id']. ')" href="javascript:;">重新购买</a><a onclick="delthis(' .$row['order_id']. ')" href="javascript:;">删除记录</a>'; } $row['shipping_status'] = ($row['shipping_status'] == SS_SHIPPED_ING) ? SS_PREPARING : $row['shipping_status']; $row['order_status'] = $GLOBALS['_LANG']['os'][$row['order_status']] . ',' . $GLOBALS['_LANG']['ps'][$row['pay_status']] . ',' . $GLOBALS['_LANG']['ss'][$row['shipping_status']]; $arr[] = array('order_id' => $row['order_id'], 'order_sn' => $row['order_sn'], 'order_time' => local_date($GLOBALS['_CFG']['time_format'], $row['add_time']), 'order_status' => $row['order_status'], 'total_fee' => price_format($row['total_fee'], false), 'shipping_fee' => $row['shipping_fee'], 'handler' => $row['handler']); } return $arr; }
3,themesdefaultuser_transaction.dwt
找到
<!-- {if $action eq 'order_list'} --> ... <!--{/if}-->
替换成
<!--#订单列表界面 start--> <!-- {if $action eq 'order_list'} --> <h5><span>{$lang.label_order}</span></h5> <div class="blank"></div> <link href="{$ecs_themes_path}order_list.css" rel="stylesheet" type="text/css"/> <div id="main-content"> <div class="remide-box"> <h3>我的交易提醒:</h3> <ul> <li>待付款<span class="num">({$unpayed})</span></li> <li>待确认收货<span class="num">({$received})</span></li> <li>待发货<span class="num">({$confirmed})</span></li> <li>交易成功<span class="num">({$done})</span></li> </ul> </div> <table class="bought-table"> <thead> <tr class="col-name"> <th></th> <th class="baobei">宝贝</th> <th class="price">单价(元)</th> <th class="quantity">数量</th> <th class="after-service">售后</th> <th class="amount">实付款(元)</th> <th class="trade-status">交易状态</th> <th class="operate">交易操作</th> </tr> </thead> <!--{foreach from=$orders item=item}--> <tbody class="{if $item.order_status == '已取消,未付款,未发货'}close-order {/if}xcard"> <tr class="sep-row"> <td colspan="8"></td> </tr> <tr class="order-hd"> <td style="padding-left:5px;" colspan="8"> <span class="no"><label>订单编号:<span class="order-num">{$item.order_sn}</span></label></span> <span class="deal-time">成交时间:{$item.order_time}</span> </td> </tr> <!--{foreach from=$item.goods item=goods_info name=foo}--> <tr class="order-bd<!--{if $item.goods_number > 0 && $smarty.foreach.foo.iteration == $item.goods_number}--> last<!--{/if}-->"> <td colspan="2" class="baobei"> <a class="pic" href="goods.php?id={$goods_info.goods_id}" title="查看宝贝详情" hidefocus="true" target="_blank"><img src="{$goods_info.goods_thumb}" alt="查看宝贝详情"></a> <div class="desc"> <a href="goods.php?id={$goods_info.goods_id}" target="_blank" class="baobei-name">{$goods_info.goods_name}</a> <div class="spec"> <span>{$goods_info.goods_attr}</span> </div> </div> </td> <td title="{$goods_info.goods_price}" class="price">{$goods_info.goods_price}</td> <td title="{$goods_info.goods_number}" class="quantity">{$goods_info.goods_number}</td> <td class="after-service"> <a href="user.php?act=message_list&order_id={$item.order_id}" target="_blank" class="tousu-weiquan J_MakePoint J_HasBuy J_ApplyRepayTrigger">投诉留言</a> </td> <!--{if $smarty.foreach.foo.iteration == 1}--> <td rowspan="{$item.goods_number}" class="amount"> <strong>{$item.total_fee}</strong> <p class="post-type"> ({if $item.shipping_fee}含快递:{$item.shipping_fee}{else}商家包邮{/if}) </p> </td> <td rowspan="{$item.goods_number}" class="trade-status"> {if $item.order_status == '未确认,未付款,未发货' || $item.order_status == '已确认,未付款,未发货'} <a class="J_MakePoint status todo" target="_blank" href="user.php?act=order_detail&order_id={$item.order_id}">等待付款订单</a> <a class="detail-link J_MakePoint" href="user.php?act=order_detail&order_id={$item.order_id}">订单详情</a> {elseif $item.order_status == '已确认,已付款,未发货'} 等待发货 <a class="detail-link J_MakePoint" href="user.php?act=order_detail&order_id={$item.order_id}">订单详情</a> {elseif $item.order_status == '已确认,已付款,配货中'} 配货中 <a class="detail-link J_MakePoint" href="user.php?act=order_detail&order_id={$item.order_id}">订单详情</a> {elseif $item.order_status == '已确认,已付款,收货确认'} <a class="J_MakePoint status success" target="_blank" href="#">交易成功 </a> <a class="detail-link J_MakePoint" href="user.php?act=order_detail&order_id={$item.order_id}">订单详情</a> <a class="detail-link J_MakePoint" href="user.php?act=order_detail&order_id={$item.order_id}">查看物流</a> {elseif $item.order_status == '取消,未付款,未发货'} 订单已取消 {elseif $item.order_status == '已取消,未付款,未发货'} <a class="J_MakePoint status closed" target="_blank" href="user.php?act=order_detail&order_id={$item.order_id}">交易关闭</a> <a class="detail-link J_MakePoint" href="user.php?act=order_detail&order_id={$item.order_id}">订单详情</a> {else} <a class="J_MakePoint status todo" target="_blank" href="user.php?act=order_detail&order_id={$item.order_id}">订单已发货</a> <a class="detail-link J_MakePoint" href="user.php?act=order_detail&order_id={$item.order_id}">订单详情</a> <a class="detail-link J_MakePoint" href="user.php?act=order_detail&order_id={$item.order_id}">查看物流</a> {/if} </td> <td rowspan="{$item.goods_number}" class="operate"> {$item.handler} </td> <!--{/if}--> </tr> <!--{/foreach}--> </tbody> <!--{/foreach}--> <tfoot> <tr class="sep-row"> <td colspan="8"> <script type="text/javascript"> function delthis(orderId) { if(confirm("您确定要删除此条购物记录吗?")) { Ajax.call('user.php?act=delthis', 'order_id=' + orderId, delthisResponse, 'POST', 'JSON'); } } function delthisResponse(result) { alert(result.message); location.reload(); } </script> </td> </tr> <tr class="toolbar"> <td colspan="8" class="page-nav-cell"> <ul class="page-nav"> <!-- #BeginLibraryItem "/library/pages.lbi" --><!-- #EndLibraryItem --> </ul> </td> </tr> </tfoot> </table> <div class="blank5"></div> <h5><span>{$lang.merge_order}</span></h5> <div class="blank"></div> <script type="text/javascript"> {foreach from=$lang.merge_order_js item=item key=key} var {$key} = "{$item}"; {/foreach} </script> <form action="user.php" method="post" name="formOrder" onsubmit="return mergeOrder()"> <table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#dddddd"> <tr> <td width="22%" align="right" bgcolor="#ffffff">{$lang.first_order}:</td> <td width="12%" align="left" bgcolor="#ffffff"><select name="to_order"> <option value="0">{$lang.select}</option> {html_options options=$merge} </select></td> <td width="19%" align="right" bgcolor="#ffffff">{$lang.second_order}:</td> <td width="11%" align="left" bgcolor="#ffffff"><select name="from_order"> <option value="0">{$lang.select}</option> {html_options options=$merge} </select></td> <td width="36%" bgcolor="#ffffff"> <input name="act" value="merge_order" type="hidden" /> <input type="submit" name="Submit" class="bnt_blue_1" style="border:none;" value="{$lang.merge_order}" /></td> </tr> <tr> <td bgcolor="#ffffff"> </td> <td colspan="4" align="left" bgcolor="#ffffff">{$lang.merge_order_notice}</td> </tr> </table> </form> </div> <!--{/if}--> <!--#订单列表界面 end-->
ps:上面的 {$ecs_themes_path} 是我在includes/init.php里面加入的自定义当前模板路径变量
4,includes/init.php 里面找到
if (!empty($_CFG['stylename'])) { $smarty->assign('ecs_css_path', 'themes/' . $_CFG['template'] . '/style_' . $_CFG['stylename'] . '.css'); } else { $smarty->assign('ecs_css_path', 'themes/' . $_CFG['template'] . '/style.css'); }
在它下面加入
if (!empty($_CFG['stylename'])) { $smarty->assign('ecs_css_path', 'themes/' . $_CFG['template'] . '/style_' . $_CFG['stylename'] . '.css'); } else { $smarty->assign('ecs_css_path', 'themes/' . $_CFG['template'] . '/style.css'); } //自定义当前使用的模板路径 by neo $smarty->assign('ecs_themes_path', 'themes/' . $_CFG['template'] . '/');
上面需要用到的CSS文件和图片,下面下载。
打包下载:
[fo_hide]ecshop仿淘宝用户订单列表.zip 密码: hhd1[/fo_hide]
阅读剩余
版权声明:
作者:z1988
链接:https://www.z1988.com/389.html
文章版权归作者所有,未经允许请勿转载。
作者:z1988
链接:https://www.z1988.com/389.html
文章版权归作者所有,未经允许请勿转载。
THE END