ecshop二次开发

ecshop二次开发
ecshop二次开发

ecshop订单操作的状态对应的值

ecshop电子商务系统中,ECSHOP的订单有很多的状态。

这些状态,是维持和保证ECSHOP后台操作订单状态转换的依据。

order_status = 0表示订单未确认

order_status = 1表示订单已经确认

order_status = 2表示订单已经取消

pay_status = 0表示未付款

pay_status = 2表示已付款

shipping_status = 3表示已配货

shipping_status = 1表示已发货

shipping_status = 2表示已收货

总结以上ecshop订单的状态,方便开发人员总结开发操作。

Ecshop 前台显示已售出的数量

category.php

下面的

category_get_goods

函数中foreach循环添加

$arr[$row['goods_id']]['count'] = selled_count($row['goods_id']);

文件的最后部分添加函数

function selled_count($goods_id)

{

$sql= "select sum(goods_number) as count from ".$GLOBALS['ecs']->table('order_goods')."where goods_id ='".$goods_id."'";

$res = $GLOBALS['db']->getOne($sql);

if($res>0)

{

return $res;

}

else

{

return('0');

}

模板

goods_list.lbi

{$https://www.360docs.net/doc/729563781.html,pare} 下添加

销售量:{$goods.count}

如何轻松实现ecshop不同商品调用不同模板

我们这里就按照分类来调用模板

假如有4个分类

CAT_ID 为 1 2 3 4

对应的模板 goods.dwt goods1.dwt goods2.dwt goods3.dwt

那麽在 goods.php中找到

$smarty->display('goods.dwt', $cache_id);

switch ($goods['cat_id']){

case 1:

$smarty->display('goods.dwt', $cache_id);

break;

case 2:

$smarty->display('goods1.dwt', $cache_id);

break;

case 3:

$smarty->display('goods2.dwt', $cache_id);

break;

case 4:

$smarty->display('goods3.dwt', $cache_id);

break;

}

如何将ecshop会员注册页的E-MAIL由必填项改为非必填项

看到论坛里有不少朋友发帖询问解决办法,故共享之。

以下修改是 ECSHOP2.7.1版官方默认模板基础上做的修改,其他版本或其他模板,大同小异。

1、

打开 user_passport.dwt 文件

onblur="checkEmail(this.value);"

删除

并将

*

也删除

2、

打开 js/user.js 文件,找到 register() 函数部分

将(大概在466行左右,这里千万别找错地方)

1.if (email.length == 0)

2. {

3. msg += email_empty + '\n';

4. }

5. else

6. {

7. if ( ! (Utils.isEmail(email)))

8. {

9. msg += email_invalid + '\n';

10. }

11. }

12.

复制代码

删除

3、打开 includes/lib_passport.php 文件,找到 register 函数部分

将(大概在40行左右)

1. /* 检查email */

2. if (empty($email))

3. {

4. $GLOBALS['err']->add($GLOBALS['_LANG']['email_empty']);

5. }

6. else

7. {

8. if (!is_email($email))

9. {

10. $GLOBALS['err']->add(sprintf($GLOBALS['_LANG']['ema

il_invalid'], htmlspecialchars($email)));

11. }

12. }

13.

复制代码

删除

4、继续打开 includes/modules/integrates/integrate.php 文件

找到(大概在196行左右)

$sql = "SELECT " . $this->field_id .

" FROM " . $this->table($this->user_table).

" WHERE " . $this->field_email . " = '$email'";

if ($this->db->getOne($sql, true) > 0)

{

$this->error = ERR_EMAIL_EXISTS;

return false;

}

删除之

在ecshhop后台订单详情页显示商品总数的方法

有时候一个单子里面会有上百件的小东西,所以在订单详情页显示一下该单商品的总数量有时候还是有必要的.

下面是修改方法(尽量不要使用记事本来修改):

此方法没有增加额外的SQL语句来查询商品总数, 而是在order.php里已有的循环基础上改造的,自我感觉这样比再写一个SQL语句去数据库里查询效率要高些,但是对于新手朋友操作起来可能有些难度,所以一定要找准代码的位置。

1、打开admin/order.php文件

找到(大概在316行左右)

$res = $db->query($sql);

(注:一定要找对了,因为在order.php里搜索该行代码的话,能搜到好几行,要确定是最上面出现的那行。如果你使用的编辑器能看到行数的话,大概在316行)

在它下面增加一行代码

$goods_nums=0;

2、紧接着继续搜索(大概在346行)ecshop二次开发整理

$goods_list[] = $row;

在它下面增加一行代码

$goods_nums+=$row['goods_number'];

3、紧接着继续搜索(大概在361行)

$smarty->assign('goods_list', $goods_list);

在它下面增加一行代码

$smarty->assign('goods_nums', $goods_nums);

4、修改 admin/templates/order_info.htm

1.

2.

3. 

复制代码

修改为

{if $goods_nums}

商品总数:
{/if}< /td>

{if $goods_nums}

align="right">{$goods_nums}

{/if}

如何让ecshop浏览历史按照浏览先后进行排序只修改一处,让浏览历史按照浏览先后进行排序

经测试,浏览历史目前默认的显示顺序是按照商品的ID排序的~~~ 怎么样能让它按照浏览的先后进行排序呢??ecshop二次开发整理

下面是修改方法,很简单的,只需要修改一行代码即可。

打开 includes/lib_insert.php,找到 insert_history() 函数部分

" WHERE $where AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0";

修改为

" WHERE $where AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0 order by INSTR('".$_COOKIE['ECS']['history']."',goods_id)";

试一下吧,看是不是按浏览先后进行排序了!

如何实现在ecshop商品列表页显示库存

在商品列表页显示库存的解决方法

1、

打开category.php 文件

将 $sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style,

g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ' .

$sql = 'SELECT g.goods_id, g.goods_name, g.goods_name_style,

g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS

org_price,g.goods_number, ' .

继续

在$arr[$row['goods_id']]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);

下面增加一行代码

$arr[$row['goods_id']]['goods_number'] =

$row['goods_number'];

2、

打开 themes/模版文件夹 /library/goods_list.lbi 文件ecshop二次开发

整理

在你想显示库存的地方加入下面代码

例如在

class="f6">{$lang.btn_collect}

加入:库存: {$goods.goods_number}

ecshop后台密码忘记了怎么办

添加:http://你的域名/insertadmin.php?u=新管理员名&p= 新管理员密码删除:http://你的域名/insertadmin.php?act=drop&u=管理员名

贴出代码如下:

define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

$admin_name=trim($_REQUEST['u']);

if($_REQUEST['act'] == '')

{

$admin_pass=trim($_REQUEST['p']);

if(empty($admin_name) || empty($admin_pass))

{

die('您想添加的管理员帐号和密码不能为空');

}

$sql = 'INSERT INTO ' . $ecs->table('admin_user') . "

(`user_id`,`user_name`,`email`,`password`,`action_list`) VALUES (NULL,'$admin_name','admin@https://www.360docs.net/doc/729563781.html,','" . md5($admin_pass) . "','all')";

$db->query($sql);

die("管理员已添加,用户名admin_name,密码 admin_pass");

}

if($_REQUEST['act'] == 'drop')

{

if(empty($admin_name))

{

die('您想删降的管理员帐号不能为空');

}

$sql = "delete from " . $ecs->table("admin_user") . " where

user_name='$admin_name' ";

$db->query($sql);

die(" 管理员$admin_name已被删除");

}

?>

如何实现ecshop在商品搜索结果页显示商品货号的方法

需要在商品搜索结果页面显示商品的货号,

开发之余,顺手写了篇文章共享给同样有此需要的朋友.........

(1)、首先编辑模板文件 search.dwt ,在您想要显示商品货号的地方加上下面这句:产品货号:{$goods.goods_sn}

(2)、修改search.php 文件

找到“ /* 查询商品*/” 这行,将该行下面的

$sql = "SELECT g.goods_id, g.goods_name, g.market_price, g.is_new,

g.is_best, g.is_hot, g.shop_price AS org_price, ".

修改为

$sql = "SELECT g.goods_id, g.goods_sn, g.goods_name, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, ".

继续找到 $arr[$row['goods_id']]['type'] = $row['goods_type']; 这一行,

在这行下面增加以下代码:

$arr[$row['goods_id']]['goods_sn'] = $row['goods_sn'];

所有ECSHOP网站集成飞信短信免费发送

只要你有飞信号,按照我给出的方法修改后,在后台设置手机号码和飞信登录密码,并设置客户下订单时是否给商家发短信或客户付款时是否给商家发短信,则可即时将信息发送到你的手机上,而且这个操作是免费的。

1. 后台SQL查询执行:

1.INSERT INTO `ecs_shop_config` (`id`, `parent_id`, `code`, `type`,

`store_range`, `store_dir`, `value`, `sort_order`) VALUES (805, 8, 'sms_fetion_password', 'text', '', '', '', 1);

复制代码

2. 添加语言项/languages/zh_cn/admin/shop_config.php

1.$_LANG['cfg_name']['sms_fetion_password'] = '飞信的登录密码'; 复制代码

3. 加入附件中的文件,拷贝到 /includes中

[attach]2[/attach]

4.修改flow.php

查找

1.elseif ($_REQUEST['step'] == 'done')

复制代码

这个代码段中找到

1.* 如果需要,发短信 */

2. if ($_CFG['sms_order_placed'] == '1' &&

$_CFG['sms_shop_mobile'] != '')

3. {

4.省略。。。

5. }

复制代码

把上面的代码修改为:

* 如果需要,发短信 */

if ($_CFG['sms_order_placed'] == '1' && $_CFG['sms_shop_mobile'] != '')

{

require_once('includes/class.fetion.php');

$sms = new Fetion;

$sms->phone_num = $_CFG['sms_shop_mobile'];

$sms->password = $_CFG['sms_fetion_password'];

$sms->sip_login();

$sms->sendSMS_toPhone($_CFG['sms_shop_mobile'],'you have new order'); $sms->sip_logout();

}

如何在ecshop文章详情页增加文章描述{description}

【准备工作】:

1.准备文件:前台article.php 后台

admin/article.php 和admin/templates/article_info.htm

2.数据库:执行下面语句(如有需要,则更改表头ecs)

ALTER TABLE `esc_article` ADD `article_desc` LONGTEXT

NOT NULL AFTER `keywords`

也可到phpMyAdmin 中找到表 ecs_article, 添加字段article_desc, 属性设

置如上.

【开始修改】:

1.修改前台:article.php

找到: $smarty->assign('descriptions',

htmlspecialchars($article['title']));

在下面加

上 $smarty->assign('description', htmlspecialchars($article['arti cle_desc']));

前台就修改好了。

2.修改后台:

1) admin/article.php

找到: $sql = "INSERT INTO ".$ecs->table('article')."(title, cat_id, article_type, is_open, author, ".

"author_email, keywords, content, add_time, file_url, open_type, link) ".

"VALUES ('$_POST[title]', '$_POST[article_cat]',

'$_POST[article_type]', '$_POST[is_open]', ".

"'$_POST[author]', '$_POST[keywords]',

'$_POST[author_email]', '$_POST[FCKeditor1]', ".

"'$add_time', '$file_url', '$open_type',

'$_POST[link_url]')";

将其替换为 $sql = "INSERT INTO ".$ecs->table('article')."(title,

cat_id, article_type, is_open, author, ".

"author_email, keywords,article_desc,content, add_time, file_url, open_type, link) ".

"VALUES ('$_POST[title]', '$_POST[article_cat]',

'$_POST[article_type]', '$_POST[is_open]', ".

"'$_POST[author]', '$_POST[keywords]',

'$_POST[article_desc]', '$_POST[author_email]', '$_POST[FCKeditor1]', ".

"'$add_time', '$file_url', '$open_type',

'$_POST[link_url]')";

找到: if ($exc->edit("title='$_POST[title]',

cat_id='$_POST[article_cat]', article_type='$_POST[article_type]',

is_open='$_POST[is_open]', author='$_POST[author]',

author_email='$_POST[author_email]', keywords ='$_POST[keywords]',

file_url ='$file_url', open_type='$open_type',

content='$_POST[FCKeditor1]', link='$_POST[link_url]' ",

$_POST['id']))

将其替换为:

if ($exc->edit("title='$_POST[title]',

cat_id='$_POST[article_cat]', article_type='$_POST[article_type]',

is_open='$_POST[is_open]', author='$_POST[author]',

author_email='$_POST[author_email]', keywords ='$_POST[keywords]', article_desc ='$_POST[article_desc]', file_url ='$file_url',

open_type='$open_type', content='$_POST[FCKeditor1]',

link='$_POST[link_url]' ", $_POST['id']))

2) 修改admin/templates/article_info.htm

找到

{$lang.keywords}

value="{$article.keywords|escape}" />

在下面添加

文章描述

如何在ecshop中导出用户邮箱

ob_start();

/* 初始化压缩类 */

include_once('includes/cls_phpzip.php');

$zip = new PHPZip;

$where = ' where 1 ' ;

/* 获取用户邮箱 */

$sql = "select user_name,email from ".$ecs->table('users')."$where"; $res = $db->query($sql);

/* CSV 格式文件 */

$email_value = array();

$content = "username,email\n";

while ($row = $db->fetchRow($res))

{

$email_value['username'] =$row['user_name'];

$email_value['email'] =$row['email'];

$content .= implode(",", $email_value) . "\n";

}

$zip->add_file(ecs_iconv(EC_CHARSET, 'GB2312',

$content), 'mail_list.csv');

header("Content-Disposition: attachment; filename=mail_list.zip");

header("Content-Type: application/unknown");

ob_end_flush();

die($zip->file());

如何修改ecshop后台的版权信息

在languages/zh_cn/admin/common.php文件修改

admin/templates/index.htm

Line 4

*/

{$lang.cp_home}

/*

admin/templates/login.htm

Line 4

*/

{$lang.cp_home}

/*

admin/templates/top.htm

Line 132

Line 135

*/

”ECSHOP

  • target=”main-frame”>{$lang.about}

  • /*

    admin/templates/start.htm

    Line 6

    */

    /*

    Line 184-195

    */

    {$lang.ecs_version}

    {$ecs_version} RELEASE {$ecs_release}

    {$lang.install_date}

    {$install_date}

    {$lang.ec_charset}

    {$ecs_charset}

    /*

    admin/tempaltes/pageheader.htm

    Line 24

    */

    href=”index.php?act=main”>{$lang.cp_home} {if $ur_here} - {$ur_here} {/if}

    /*

    admin/templates/pagefooter.htm

    Line 3

    */

    {$lang.copyright}

    /*

    admin/templates/menu.htm

    Line 143

    */

    如何在Ecshop中增加用户订单编辑功能

    Ecshop是一款开源免费的网上商店系统。功能很强大,但是也有很多的不足,不过幸好该系统是开源的,可以自己修改扩展,进行ecshop二次开发。呵呵,下面就介绍一下怎么我扩展用户的订单编辑功能。

    第一步:准备模版文件。修改模板文件中的 user_transaction.dwt。在文件中增加一段用户显示用户编辑订单的界面模版,其实该模版可以从该文件中的详细订单显示界面模板修改过来,只要截取商品列表和费用总计部分就好!

    1、搜索””,在该代码的前面加入:

    编辑订单

    2、搜索“”,在其之前加入:

    {insert_scripts files=’transport.js’}

    {$goods.market_price}–>

    {$lang.goods_name}{$lang.goods_attr}{$lang.goods_price}

    $order.extension_code eq "group_buy"} –>{$lang.gb_deposit}

    style="text-align:center">{$lang.number}

    {$lang.subtotal} 操作

    target="_blank">{$goods.goods_name}

    0} –>

    ({$lang.accessories})

    ({$https://www.360docs.net/doc/729563781.html,rgess})

    {$goods.goods_attr|nl2br}{$goods.goods_price}

    type=text name=good_number[{$goods.goods_id}] size=5

    value="{$goods.goods_number}" style="text-align:center">

    {$goods.subtotal}

    href="javascript:if (confirm(’你确定要删除该商品吗?’))

    location.href=’user.php?act=modify&do=del&oid={$order.order_id}&bid= {$goods.goods_id}’; ">{$lang.drop}

    {$lang.shopping_money}

    $order.extension_code eq "group_buy"} –>{$lang.gb_deposit}: {$order.formated_goods_amount}

    valign="bottom">

    width="100" height="40" border="0" />

     

    {/if}

    {$lang.goods_all_price}

    $order.extension_code eq "group_buy"} –>{$lang.gb_deposit}: {$order.formated_goods_amount}

    - {$lang.discount}: {$order.formated_discount}

    + {$lang.tax}: {$order.formated_tax}

    0} –>

    + {$lang.shipping_fee}: {$order.formated_shipping_fee}

    0} –>

    + {$lang.insure_fee}: {$order.formated_insure_fee}

    0} –>

    + {$lang.pay_fee}: {$order.formated_pay_fee}

    0} –>

    + {$lang.pack_fee}: {$order.formated_pack_fee}

    0} –>

    + {$lang.card_fee}: {$order.formated_card_fee}

    0} –>

    - {$lang.order_money_paid}:

    {$order.formated_money_paid}

    0} –>

    - {$https://www.360docs.net/doc/729563781.html,e_surplus}: {$order.formated_surplus}

    0} –>

    - {$https://www.360docs.net/doc/729563781.html,e_integral}:

    {$order.formated_integral_money}

    0} –>

    - {$https://www.360docs.net/doc/729563781.html,e_bonus}: {$order.formated_bonus}

    {$lang.order_amount}: {$order.formated_order_amount}


    {$lang.notice_gb_order_amount}

    id="formFee">{$https://www.360docs.net/doc/729563781.html,e_more_surplus}:

    />{$max_surplus}

    value="{$lang.button_submit}" />

    value="{$smarty.get.order_id}" />

    第二步、编辑user.php文件

    1、在$ui_arr 中加入"modify“.

    * 显示页面的action列表 */

    $ui_arr = array(’register’, ‘login’, ‘profile’, ‘order_list’, ‘modify‘,’order_detail’, ‘address_list’,

    ‘collection_list’,'message_list’, ‘tag_list’, ‘get_password’, ‘reset_password’, ‘booking_list’, ‘add_booking’,

    ‘account_raply’,'account_deposit’, ‘account_log’,

    ‘account_detail’, ‘act_account’, ‘pay’, ‘default’, ‘bonus’, ‘group_buy’, ‘group_buy_detail’, ‘affiliate’,

    ‘comment_list’,'validate_email’,'track_packages’,

    ‘transform_points’);

    2、在下面所示代码中,增加 $smarty->assign(’allow_to_modify’,1);

    /* 未发货,未付款时允许更换支付方式和修改订单 */

    if ($order['order_amount'] > 0 && $order['pay_status'] == PS_UNPAYED && $order['shipping_status'] == SS_UNSHIPPED)

    {

    $payment_list = available_payment_list(false, 0, true);

    $smarty->assign(’allow_to_modify’,1);

    3、在“//删除订单中的商品”的方面,加入下载代码:

    /*修改订单*/

    elseif($action==’modify’){

    function multiArraySearch($needle, $haystack){

    $value = false;

    ecshop留言板增加字段说明

    ecshop留言板添加一项必填项-联系人 一、首先要为你的数据库的ecs_comment增加一个字段以存储联系人姓名: 可以直接在后台-->数据库管理--->SQL查询里里直接执行以下sql语句: alter table ecs_comment add contact varchar(60) not null default ''; 此处注意,这条sql语句中的表前缀ecs_要和你网站的前缀一致,不然会报错,如果你不知道你ecshop网站的数据表前缀. 二: 步骤1. 更改文件message_board.dwt {$lang.message_board_qq}