总结ecshop二次开发50个小技巧
2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家
最近很忙,也没时间去打理一些资料和开发笔记,去年总结了使用ecshop电子商务系统的100个小问题,被ecshop爱好的朋友大量转载,今年应更多朋友的邀请。总结50条ecshop二次开发小技巧。希望对大家有所帮助。我将尽力快速的完成完善本文.但是有一点,不会说的太详细,也不会有完整的代码。只提供思路给大家.
回答count = $db -> getOne("select sum(goods_number) from ".$ecs->table('order_goods')." where goods_id = '$goods[goods_id]'");
回答: <script> 3:如何用js去验证手机号码. 回答:var reg =/^[1]([3][0-9]{1}|50|53|59|58|56|86|80|89|87|88|85|86|55|51|52|57)[0-9]{8}$/; 4:ecshop中如何取得每个月的1号时间? 回答:local_mktime(0,0,0,date("m"),0,date("Y"));使用ecshop的local_mktime函数. 5:ecshop如何直接关闭窗口而不弹出提示 回答:<a href="javascript:window.opener=null;window.close();"> 6:如何统计ecshop某商品下被审核过的评论数量。 回答:$ccount = $db -> getOne("select count(*) cc from ".$ecs->table('comment')." where id_value = '$goods_id' and comment_type = '0' and status = '1' and parent_id = '0'"); 有关ecshop评论,请参考本文 7:ecshop中js如何将时间格式互转 回答:date1 = new Date(); 8:如何解析ecshop flash的xml 回答: $str = @file_get_contents("data/flash_data.xml"); } 回答:preg_match("/[".chr(0xa1)."-".chr(0xff)."]+/",ecs_iconv("UTF-8","GBK",$v['brand_name']),$cn); 10:ecshop如何取得订单中所属区域 $p = $GLOBALS['db']->getOne("select region_name from ".$GLOBALS['ecs']->table('region')." where region_id = '".$re1['province']."'"); 11:ecshop中如何分别提取中文和英文 回答:utf下面 $pregstr = "/[\x{4e00}-\x{9fa5}]+/u"; gbk下面 $strtest = “yyg中文字符yyg”; $pregstr = "/([".chr(0xb0)."-".chr(0xf7)."][".chr(0xa1)."-".chr(0xfe)."])+/i"; if(preg_match($pregstr,$strtest,$matchArray)){ echo $matchArray[0]; } 12:如何控制ecshop商品[/url]总价格只有ecshop会员特殊等级才能查看 回答:ecshop的goods.php $is_spe = $GLOBALS['db'] -> getOne("select special_rank from ".$GLOBALS['ecs']->table('user_rank')." where rank_id = '".$_SESSION['user_rank']."'"); 13:调试ecshop程序出现以下错误Fatal error: Cannot redeclare是什么意思? 回答:Fatal error: Cannot redeclare,意思是你运行的程序中,某函数重新申明了两次,要删除其中一个同名函数. |
回答:
14:ecshop如何判断是否当天登陆,并赠送积分. 回答:/* 赠送积分 */ $day = local_mktime(0,0,0,date("m"),date("d"),date("Y")); $last_time = $db -> getOne("select last_login from ".$ecs->table('users')." where user_name = '".$username."'"); if($last_time < $day){ log_account_change($_SESSION['user_id'], 0, 0, 0, 10, '每天登陆送积分', ACT_OTHER); } 15:如何在ecshop订单列表中列表出订单中所包含的商品编号. 回答: function get_user_orders($user_id, $num = 10, $start = 0) { /* 取得订单列表 */ $arr = array(); global $ecs; global$db; $sql = "SELECT order_id, order_sn, order_status,consignee, 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' ORDER BY add_time DESC"; $res = $GLOBALS['db']->SelectLimit($sql, $num, $start); while ($row = $GLOBALS['db']->fetchRow($res)) { if ($row['order_status'] == OS_UNCONFIRMED) { $row['handler'] = "<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_SLITED) { /* 对配送状态的处理 */ if ($row['shipping_status'] == SS_SHIPPED) { @$row['handler'] = "<a href=\"user.php?act=affirm_received&order_id=" .$row['order_id']. "\" onclick=\"if (!confirm('".$GLOBALS['_LANG']['confirm_received']."')) return false;\">".$GLOBALS['_LANG']['received']."</a>"; } elseif ($row['shipping_status'] == SS_RECEIVED) { @$row['handler'] = '<span style="color:red">'.$GLOBALS['_LANG']['ss_received'] .'</span>'; } else { if ($row['pay_status'] == PS_UNPAYED) { @$row['handler'] = "<a href=\"user.php?act=order_detail&order_id=" .$row['order_id']. '">' .$GLOBALS['_LANG']['pay_money']. '</a>'; } else { @$row['handler'] = "<a href=\"user.php?act=order_detail&order_id=" .$row['order_id']. '">' .$GLOBALS['_LANG']['view_order']. '</a>'; } } } else { $row['handler'] = '<span style="color:red">'.$GLOBALS['_LANG']['os'][$row['order_status']] .'</span>'; } $row2 = $db -> getAll("select goods_id ,goods_sn from ".$ecs->table('order_goods')." where order_id = '".$row['order_id']."'"); $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'], 'consignee'=> $row['consignee'], 'total_fee'=> price_format($row['total_fee'], false), 'goodslist'=> $row2, 'handler'=> $row['handler']); } return $arr; } 16:如何取得ecshop会员一天内的评论条数 回答: function get_day_count_comment($user_id = ''){ global $db; global $ecs; $pre = local_mktime(0,0,0,date("m"),date("d"),date("y")); $next = local_mktime(0,0,0,date("m"),date("d")+2,date("y")); $count = $db -> getOne("select count(*) from ".$ecs->table('comment')." where user_id = '$user_id' and add_time > '$pre' and add_time < '$next' "); if($count > 5){ return false; }else{ return true; } } 17:ecshop中js是如何验证radio选择. 回答:类似以下代码 /* var businesstype = false; var job_title = false; var number_of_employees = false; for (i = 0; i < frm.elements.length; i ++ ) { if (frm.elements[i].name == 'businesstype' && frm.elements[i].checked) { businesstype = true; } if (frm.elements[i].name == 'job_title' && frm.elements[i].checked) { job_title = true; } if (frm.elements[i].name == 'number_of_employees' && frm.elements[i].checked) { number_of_employees = true; } if (frm.elements[i].name == 'number_of_employees' && frm.elements[i].checked) { number_of_employees = true; } } */ 18:如何增加mysql的连接数量。让ecshop更稳定. 回答:进入mysql命令模式下。执行该SQL语句 set global max_connections=500; show variables; 19:如何让ecshop模板中的table文字处置居中 回答: style="vertical-align:middle; " 属性就可以了 20:如何建立msyql一默认字段为时间格式.默认为系统时间. 回答:alter table ecs_b add column age times**p DEFAULT now() 21:如何控制js只输入数字. 回答:<input name="quatity" type="text" class="input2" value="0" size="6" onKeyUp="value=value.replace(/[^\d]/g,'')"> 22:ecshop中如何用正则去匹配sql语句. 回答:return preg_replace("/\s*select\s+(\*|[\w_]+(\s*,\s*[\w_]+)*)\s+from\s+[\w_]+(\s+where\s+[\w_]+\s*=\s*\S+)?(\s+order\s+by\s+[\w_]+ (\s+(ASC|DESC))?)?\s*$/i","",$sql); 23:如何删除ecshop中url特殊字符 回答: if ($rewrite == 2 && !empty($append)) { //$uri .= '-' . urlencode(preg_replace('/[\.|\/|\?|&|\+|\\\|\'|"|,]+/', '', $append)); //$uri=str_replace('+','-',$uri); $str = preg_replace('/[\.|\/|\?|&|\+|\\\|\'|"|,]+/', '', $append); $ar= array('('=>'',')'=>'','#'=>'','+'=>'-'); $str = strtr($str,$ar); $str = preg_replace("/\s+/","-",$str); $uri.=$str; } |
最近更新
常用插件
- ecshop二次开发详细页面生
插件介绍: ECSHOP系统,在很多时候,很多商品没有人购买,不但购买的人...
- ecshop2.7.1打印发货单插件
ecshop2.7.1打印发货单插件介绍:ecshop2.7.1和以前的ecshop版本不一样,ecs...
- ecshop商品分类名称增加样
ecshop插件介绍:本插件可以方便在后台管理,为ecshop商品分类名称增加样...
- ecshop二次商品订购人信息
ecshop二次商品订购人信息填写插件,有时候给朋友送花,或者是送礼品的...
- ecshop分类批量扩展插件
ecshop分类批量扩展插件,这个插件是ecshop插件里面比较核心的插件。我们...