文档库 最新最全的文档下载
当前位置:文档库 › ecshop实现在首页读取会员等级和价格的方法

ecshop实现在首页读取会员等级和价格的方法

ecshop实现在首页读取会员等级和价格的方法!

1:在.lib_goods.php 中 查找{
$type_array[$key] = array();
}
}

在其下用下面的这些替换原来的相应部分
/**
* 获得商品的详细信息
*
* @access public
* @param integer $goods_id
* @return void
*/

if( $_SESSION[user_rank] == 0 ){
$user_rank=6;
}
else{
$user_rank = $_SESSION[user_rank] ;
}
//取出所有符合条件的商品数据,并将结果存入对应的推荐类型数组中
$sql = ‘SELECT g.goods_id, g.goods_name, g.goods_name_style, g.market_price, g.shop_price AS org_price, g.promote_price, g.give_integral,https://www.wendangku.net/doc/9a12975796.html,er_rank as userrank,r.rank_name,
r.discount, IFNULL(https://www.wendangku.net/doc/9a12975796.html,er_price, r.discount*g.shop_price/100) AS rank_price,’ .
“IFNULL(https://www.wendangku.net/doc/9a12975796.html,er_price, g.shop_price * ‘$_SESSION[discount]‘) AS shop_price, “.
“promote_start_date, promote_end_date, g.goods_brief, g.goods_thumb, g.goods_img, RAND() AS rnd ” .
‘FROM ‘ . $GLOBALS['ecs']->table(’goods’) . ‘ AS g ‘ .
“LEFT JOIN ” . $GLOBALS['ecs']->table(’member_price’) . ” AS mp “.
“ON mp.goods_id = g.goods_id AND https://www.wendangku.net/doc/9a12975796.html,er_rank = ‘$user_rank’ “.
“LEFT JOIN ” . $GLOBALS['ecs']->table(’user_rank’) . ” AS r “.
“ON r.rank_id = $user_rank”;
$type_merge = array_merge($type_array['new'], $type_array['best'], $type_array['hot']);
$type_merge = array_unique($type_merge);
$sql .= ‘ WHERE g.goods_id ‘ . db_create_in($type_merge);
$sql .= ‘ ORDER BY g.sort_order, https://www.wendangku.net/doc/9a12975796.html,st_update DESC’;
$result = $GLOBALS['db']->getAll($sql);
foreach ($result AS $idx => $row)
{
if ($row['promote_price'] > 0)
{
$promote_price = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);
$goods[$idx]['promote_price'] = $promote_price > 0 ? price_format($promote_price) : ”;
}
else
{
$goods[$idx]['promote_price'] = ”;
}
$goods[$idx]['id'] = $row['goods_id'];
$goods[$idx]['name'] = $row['goods_name'];
$goods[$idx]['rank_name'] = $row['rank_name'];
$goods[$idx]['discount'] = $row['discount'];
$goods[$idx]['brief'] = $row['goods_brief'];
$goods[$idx]['brand_name'] = isset($goods_data['brand'][$row['goods_id']]) ? $goods_data['brand'][$row['goods_id']] : ”;
$goods[$idx]['goods_style_name'] = add_style($row['goods_name'],$row['goods_name_style']);
$goods[$idx]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row[

'goods_name'];
$goods[$idx]['short_style_name'] = add_style($goods[$idx]['short_name'],$row['goods_name_style']);
$goods[$idx]['market_price'] = price_format($row['market_price']);
$goods[$idx]['shop_price'] = price_format($row['shop_price']);
$goods[$idx]['rank_price'] = price_format($row['rank_price']);
$goods[$idx]['give_integral'] = $row['give_integral'];
$goods[$idx]['thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$goods[$idx]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$goods[$idx]['url'] = build_uri(’goods’, array(’gid’ => $row['goods_id']), $row['goods_name']);

if (in_array($row['goods_id'], $type_array['best']))
{
$type_goods['best'][] = $goods[$idx];
}
if (in_array($row['goods_id'], $type_array['new']))
{
$type_goods['new'][] = $goods[$idx];
}
if (in_array($row['goods_id'], $type_array['hot']))
{
$type_goods['hot'][] = $goods[$idx];
}
}
}
return $type_goods[$type];

}

2:在模版 文件中 (如: recommend_best.lbi)

{$lang.market_price}{$goods.market_price}



下面添加
添加

{$goods.rank_name}{$goods.rank_price}

在没有登陆的时候显示 普通会员价,登陆之后就显示会员对应的等级和价格。

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ECSHOP新增数据库字段后出现乱码的解决办法

有朋友在diy修改ECSHOP时,有时会需要在数据库中加入一些字段,可能在存储过程中会遇到乱码问题,要找出这个问题的原因,还真是要花些时间, 因为一开始都会想到是编码的原因, 方向错了, 自然是越
走越远了!

我这次也是在给一个客户开发时在user数据表添加字段后出现乱码,找了很久才找到解决方法!

问题出在ECSHOP在把资料放进数据库时, 经过了htmlentities的处理, 防止javascriptr的恶意输入,
文件位于/includes/lib_passport.php第165行:
原代码: $other[$key] = htmlentities($val); //防止用户输入javascript代码

只要把 htmlentities换成htmlspecialchars就OK 了

$other[$key] = htmlspecialchars($val); //防止用户输入javascript代码
另一个文件位于/includes /lib_transaction.php第85行:
原代码: $profile['other'][$key] = htmlentities($val); //防止用户输入javascript代码
修改后的代码为:
$profile['other'][$key] = htmlspecialchars($val); //防止用户输入javascript代码

ECSHOP在其他场合下是用 htmlspecialchars的, 这两个

函数功能基本一样, 只是对中文的处理结果不同.



--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

echsop商品分类实现图片的方法

1、最关键的就是在数据的category表里面加入cat_img字段,用来保存咱们的图片地址,类型就是 varchar就可以了。

2、在admin目录下面的templates的 category_info.html文件,这个是后天的模板文件,在里面加入:

分类图片:

{if $cat_info.cat_img}

{else}
”"
{/if}
3、然后修改admin目录下面的category.php文件,
在 if ($_REQUEST['act'] == ‘insert’){
后插入 $cat['cat_img'] = $image->upload_image($_FILES['cat_img']);
4、还是修改admin目录下面的category.php文件,
在 if ($_REQUEST['act'] == ‘update’)

{
/* 权限检查 */
admin_priv(’cat_manage’); 后面插入

$image = $image->upload_image($_FILES['cat_img']);
if(!empty($image))
{
$cat['cat_img'] = $image;
}

5、还是修改 admin目录下面的category.php文件
在大概18行左右 require(dirname(__FILE__) . ‘/includes/init.php’);

后插入下面两行
include_once(ROOT_PATH . ‘includes/cls_image.php’);
$image = new cls_image($_CFG['bgcolor']);

6、 修改前台调用分类模板文件!
模板调用(有图片就显示图片 没图就分类名称!)

{if $child.cat_img }
”"
{else}
{$https://www.wendangku.net/doc/9a12975796.html,|escape:html}
{/if}


7、还需修改includes目录下lib_goods.php 代码如下,这段代码是2.70的 如果你的程序是不是2.7 你也可以用下面这段代码替换,都是可以实现的@

/**
* 获得指定分类同级的所有分类以及该分类下的子分类
*
* @access public
* @param integer $cat_id 分类编号
* @return array
*/
function get_categories_tree($cat_id = 0)
{
if ($cat_id > 0)
{
$sql = ‘SELECT parent_id FROM ‘ . $GLOBALS['ecs']->table(’category’) . ” WHERE cat_id = ‘$cat_id’”;
$parent_id = $GLOBALS['db']->getOne($sql);
}
else
{
$parent_id = 0;
}

/*
判断当前分类中全是是否是底级分类,
如果是取出底级分类上级分类,
如果不是取当前分类及其下的子分类
*/
$sql = ‘SELECT count(*) FROM ‘ . $GLOBALS['ecs']->table(’category’) . ” WHERE parent_id = ‘$parent_id’ AND is_show = 1 “;
if ($GLOBALS['db']->getOne($sql) || $parent_id == 0)
{
/* 获取当前分类及其子分类 */
$sql = ‘SELECT cat_id,cat_name ,parent_i

d,is_show,cat_img ‘ .
‘FROM ‘ . $GLOBALS['ecs']->table(’category’) .
“WHERE parent_id = ‘$parent_id’ AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC”;

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

foreach ($res AS $row)
{
if ($row['is_show'])
{
$cat_arr[$row['cat_id']]['id'] = $row['cat_id'];
$cat_arr[$row['cat_id']]['name'] = $row['cat_name'];
$cat_arr[$row['cat_id']]['url'] = build_uri(’category’, array(’cid’ => $row['cat_id']), $row['cat_name']);
$cat_arr[$row['cat_id']]['cat_img'] = $row['cat_img'];

if (isset($row['cat_id']) != NULL)
{
$cat_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']);
}
}
}
}
if(isset($cat_arr))
{
return $cat_arr;
}
}

function get_child_tree($tree_id = 0)
{
$three_arr = array();
$sql = ‘SELECT count(*) FROM ‘ . $GLOBALS['ecs']->table(’category’) . ” WHERE parent_id = ‘$tree_id’ AND is_show = 1 “;
if ($GLOBALS['db']->getOne($sql) || $tree_id == 0)
{
$child_sql = ‘SELECT cat_id, cat_name, parent_id, is_show,cat_img ‘ .
‘FROM ‘ . $GLOBALS['ecs']->table(’category’) .
“WHERE parent_id = ‘$tree_id’ AND is_show = 1 ORDER BY sort_order ASC, cat_id ASC”;
$res = $GLOBALS['db']->getAll($child_sql);
foreach ($res AS $row)
{
if ($row['is_show'])

$three_arr[$row['cat_id']]['id'] = $row['cat_id'];
$three_arr[$row['cat_id']]['name'] = $row['cat_name'];
$three_arr[$row['cat_id']]['url'] = build_uri(’category’, array(’cid’ => $row['cat_id']), $row['cat_name']);
$three_arr[$row['cat_id']]['cat_img'] = $row['cat_img'];

if (isset($row['cat_id']) != NULL)
{
$three_arr[$row['cat_id']]['cat_id'] = get_child_tree($row['cat_id']);

}
}
}
return $three_arr;
}
/**
* 调用当前分类的销售排行榜
*
* @access public
* @param string $cats 查询的分类
* @return array
*/




--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ecshop实现指定商品分类的热销排行的方法

很多人要这个功能,分享如下!

在 includes/lib_goods.php
的 ecshop默认 排行 下面

加个函数

/**
* 调用指定栏目的销售排行榜
*
* @access public
* @param int $cat_id 指定的分类
* @return array
*/
function get_top10_cat($cat_id = 0)
{
if ($cat_id >0)
{
$where= “AND “.get_children($cat_id

);
}
else
{$where=”";
}

/* 排行统计的时间 */
switch ($GLOBALS['_CFG']['top10_time'])
{
case 1: // 一年
$top10_time = “AND o.order_sn >= ‘” . date(’Ymd’, gmtime() – 365 * 86400) . “‘”;
break;
case 2: // 半年
$top10_time = “AND o.order_sn >= ‘” . date(’Ymd’, gmtime() – 180 * 86400) . “‘”;
break;
case 3: // 三个月
$top10_time = “AND o.order_sn >= ‘” . date(’Ymd’, gmtime() – 90 * 86400) . “‘”;
break;
case 4: // 一个月
$top10_time = “AND o.order_sn >= ‘” . date(’Ymd’, gmtime() – 30 * 86400) . “‘”;
break;
default:
$top10_time = ”;
}

$sql = ‘SELECT g.goods_id, g.goods_name, g.shop_price, g.goods_thumb, SUM(og.goods_number) as goods_number ‘ .
’FROM ‘ . $GLOBALS['ecs']->table(’goods’) . ‘ AS g, ‘ .
$GLOBALS['ecs']->table(’order_info’) . ‘ AS o, ‘ .
$GLOBALS['ecs']->table(’order_goods’) . ‘ AS og ‘ .
”WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 $where $top10_time ” ;
//判断是否启用库存,库存数量是否大于0
if ($GLOBALS['_CFG']['use_storage'] == 1)
{
$sql .= ” AND g.goods_number > 0 “;
}
$sql .= ‘ AND og.order_id = o.order_id AND og.goods_id = g.goods_id ‘ .
”AND o.order_status = ‘” . OS_CONFIRMED . “‘ ” .
”AND (o.pay_status = ‘” . PS_PAYED . “‘ OR o.pay_status = ‘” . PS_PAYING . “‘) ” .
”AND (o.shipping_status = ‘” . SS_SHIPPED . “‘ OR o.shipping_status = ‘” . SS_RECEIVED . “‘) ” .
’GROUP BY g.goods_id ORDER BY goods_number DESC, g.goods_id DESC LIMIT ‘ . $GLOBALS['_CFG']['top_number'];
$arr = $GLOBALS['db']->getAll($sql);

for ($i = 0, $count = count($arr); $i < $count; $i++)
{
$arr[$i]['name'] = $arr[$i]['goods_name'];
$arr[$i]['url'] = build_uri(’goods’, array(’gid’ => $arr[$i]['goods_id']), $arr[$i]['goods_name']);
$arr[$i]['thumb'] = get_image_path($arr[$i]['goods_id'], $arr[$i]['goods_thumb'], true);
$arr[$i]['price'] = price_format($arr[$i]['shop_price']);
}

return $arr;
}

首页 调用在index.php也插入:(注意看这句,这里的get_top10_cat(1)中的1就是商品分类id=1的意思)

$smarty->assign(’top_goods_1′, get_top10_cat(1));

同理,比如你想调用商品分类id为 10 18 25 的这三个分类的热销排行商品,实现也就非常简单了!只要继续在index.php也添加

$smarty->assign(’top_goods_2‘, get_top10_cat(10));

$smarty->assign(’top_goods_3‘, get_top10_cat(18));

$smarty->assign(’top_goods_4‘,

get_top10_cat(25));

下面就是在模板在调用了:






{$goods.price}












{$goods.price}







注意看我红色、蓝色加粗部分的区别!

以上是首页的调用!如果你想在其他页面调用, 也需要在相应的php页面 插入

$smarty->assign(’top_goods_1′, get_top10_cat(1)); 即可!!!



非常简单


---------------------------------------------------------------------------------------------------------------------------------------------------------

ecshop2.7底部版区去除方法

先声明,本人不支持去版权,毕竟人家开源已经很不容易了!

ecshop2.7底部版权如果只是简单像以前那样在 page_footer.lbi去掉版权,你会发现底部的powered by echsop 开始随机到处乱跑!
让你抓狂,那么要如何去掉 ecshop2.7的版权呢!
在原来去版权等动作基础上关键在于ecshop2.7在 程序js目录的common.js文件,此文件添加了版权随机出现的代码!
找到第214行去掉相应的东西即可!
这样就不会2.7版权就不会乱跑了!

大概在244—336行之间,去掉这些代码就可以了!

onload = function()
{
var link_arr = document.getElementsByTagName(String.fromCharCode(65));
var link_str;
var link_text;
var regg, cc;
var rmd, rmd_s, rmd_e, link_eorr = 0;
var e = new Array(97, 98, 99,
100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
120, 121, 122
);

try
{
for(var i = 0; i < link_arr.length; i++)
{
link_str = link_arr[i].href;
if (link_str.indexOf(String.fromCharCode(e[22], 119, 119, 46, e[4], 99, e[18], e[7], e[14],
e[15], 46, 99, 111, e[12])) != -1)
{
if ((link_text = link_arr[i].innerText) == undefined)
{
throw “noIE”;
}
regg = new RegExp(String.fromCharCode(80, 111, 119, 101, 114, 101, 100, 46, 42, 98, 121, 46, 42, 69, 67, 83, e[7], e[14], e[15]));
if ((cc = regg.exec(link_text)) != null)
{
if (link_arr[i].offsetHeight == 0)
{
break;
}
link_eorr = 1;
break;
}
}
else
{
link_eorr = link_eorr ? 0 : link_eorr;
continue;
}
}
} // IE
catch(exc)
{
for(var i = 0; i < link_arr.l

ength; i++)
{
link_str = link_arr[i].href;
if (link_str.indexOf(String.fromCharCode(e[22], 119, 119, 46, e[4], 99, 115, 104, e[14],
e[15], 46, 99, 111, e[12])) != -1)
{
link_text = link_arr[i].textContent;
regg = new RegExp(String.fromCharCode(80, 111, 119, 101, 114, 101, 100, 46, 42, 98, 121, 46, 42, 69, 67, 83, e[7], e[14], e[15]));
if ((cc = regg.exec(link_text)) != null)
{
if (link_arr[i].offsetHeight == 0)
{
break;
}
link_eorr = 1;
break;
}
}
else
{
link_eorr = link_eorr ? 0 : link_eorr;
continue;
}
}
} // FF

try
{
rmd = Math.random();
rmd_s = Math.floor(rmd * 10);
if (link_eorr != 1)
{
rmd_e = i – rmd_s;
link_arr[rmd_e].href = String.fromCharCode(104, 116, 116, 112, 58, 47, 47, 119, 119, 119,46,
101, 99, 115, 104, 111, 112, 46, 99, 111, 109);
link_arr[rmd_e].innerHTML = String.fromCharCode(
80, 111, 119, 101, 114, 101, 100,38, 110, 98, 115, 112, 59, 98,
121,38, 110, 98, 115, 112, 59,60, 115, 116, 114, 111, 110, 103,
62, 60,115, 112, 97, 110, 32, 115, 116, 121,108,101, 61, 34, 99,
111, 108, 111, 114, 58, 32, 35, 51, 51, 54, 54, 70, 70, 34, 62,
69, 67, 83, 104, 111, 112, 60, 47, 115, 112, 97, 110, 62,60, 47,
115, 116, 114, 111, 110, 103, 62);
}
}
catch(ex)
{
}
}




---------------------------------------------------------------------------------------------------------------------------------------------------------


如何让ecshop所有页面显示完整的商品分类?

有很多用ecshop的朋友都希望商品分类能在所有页面全部显示出来!

今天帮人修改模板,客户要求分类树一直都完整显示,和大家分享一下:
其实很简单,

首先在 category.php 里找到
get_categories_tree($cat_id)) 改成 get_categories_tree(0))

再在 goods.php里找到

get_categories_tree($goods['cat_id'])) 改成 get_categories_tree(0))

好了,这样无论在哪一级目录都会完整显示所有分类!

希望能帮到有需要的朋友!




---------------------------------------------------------------------------------------------------------------------------------------------------------
https://www.wendangku.net/doc/9a12975796.html,/catalog.asp?cate=2

---------------------------------------------------------------------------------------------------------------------------------------------------------

目录型URL重写

第一步
加入伪静态规则
RewriteRule (.*)/(.*)-([0-9]+)\.html goods\.php\?id=$3 [N,L]
第二步
goods.dwt模板中加入
不然路径会出错
当然还有一些js中的路径都要修改为绝对路径 这个要根据模板而定 我这里就不多说了
第三步
修改 build_uri函数ecshop二次开发整理
找到

$uri .= '-' . urlencode(preg_replace('/[\.|\/|\?|&|\+|\\\|\'|"|,]+/', '', $append));

修改为

$uri = 'product/'.str_replace("+","-",urlencode(preg_replace('/[\.|\/|\?|&|\+|\\\|\'|"|,]+/', '', $append))).'-' .$uri;


--------------------------

-------------------------------------------------------------------------------------------------------------------------------

如何让ECShop支持JQuery




{$lang.cp_home}{if $ur_here} - {$ur_here} {/if}




{insert_scripts files="../js/transport.js,common.js"}
{insert_scripts files='jquery-1.3.2.min.js,jquery.json-1.3.js'}





{if $action_link}
{$action_link.text}
{/if}
{if $action_link2}
{$action_link2.text}  
{/if}
{$lang.cp_home} {if $ur_here} - {$ur_here} {/if}




---------------------------------------------------------------------------------------------------------------------------------------------------------

如何解决ecshop多货币的问题

如何解决ecshop多货币的问题

1、首先在我们的后台网店设置里要添加汇率转换的功能,如何添加网店功能自己摸索一下,你要把添加的功能插入表里。如图:
QQ截图未命名.jpg


我们的汇率都是和美元进行转换的。

2、开始前台实现:首先我们在首页加上多语言的链接如图:

我们看下他的url


这个 {$url_head} 我是重新建了一个文件 conn.php放到首页 每个文件调用
//路径处理
$url_this = "[url=http://]http://".$_SERVER[/url] ['HTTP_HOST'].$_SERVER['PHP_SELF']."?id=".$_GET['id'];
$smarty->assign("url_head",$url_this);

3、我们发现都是在每个页面后面传了一次 get值 那么在那接这些get值呢 我们肯定要找每个页面的共同文件 不难想到init.php
我在init.php的最后加入

[code]$currency = $_GET['currency'];
if($currency!=""){


$_SESSION['currency'] = $currency;
}
if($_SESSION['currency'] == '')
{
$_SESSION['currency'] = 'USD';
}

这个代码大家明白吧 我接到get值后 给了session 如果session不存在话 我们默认就是usd 这样每个页面都可以获得当前的session值 .
4、我们通过以上操作至少在每个页面可以搞定客户选的货币是什么,下来我们就考虑如何解决显示问题,如果每个页面都修改显示goods价格那多麻烦啊,我们熟悉ecshop的朋友不难想到我们所有显
示的价格都是在一个函数里进行里处理 ,这应该感谢官方的技术人员 代码写的好 当然是 lib_common.php里得price_format()这个函数 我们想一下 如果在这搞定是不是所有显示都搞定了 我们就从
这入手 以下是我修改后的函数 。ecshop 二次开发,与你分享二次开发经验。

function price_format($price, $change_price = true)
{

$currency = $_SESSION['currency'];
$rate = explode(',',$GLOBALS['_CFG']['rate']);
if($currency == 'USD')
{
$price = $price*$rate[0];
}
if($currency == 'CNY')
{

$price = $price*$rate[3];
}
if($currency == 'EUR')
{
$price = $price*$rate[1];
}
if($currency == 'GBP')
{
$price = $price*$rate[2];
}
if($currency == 'AUD')
{
$price = $price*$rate[4];
}
if ($change_price && defined('ECS_ADMIN') === false)
{
switch ($GLOBALS['_CFG']['price_format'])
{
case 0:
$price = number_format($price, 2, '.', '');
break;
case 1: // 保留不为 0 的尾数
$price = preg_replace('/(.*)(\\.)([0-9]*?)0+$/', '\1\2\3', number_format($price, 2, '.', ''));

if (substr($price, -1) == '.')
{
$price = substr($price, 0, -1);
}
break;
case 2: // 不四舍五入,保留1位
$price = substr(number_format($price, 2, '.', ''), 0, -1);
break;
case 3: // 直接取整
$price = intval($price);
break;
case 4: // 四舍五入,保留 1 位
$price = number_format($price, 1, '.', '');
break;
case 5: // 先四舍五入,不保留小数
$price = round($price);
break;
}
}
else
{
$price = number_format($price, 2, '.', '');
}
switch ($currency)
{
case 'USD':
return sprintf($GLOBALS['_CFG']['currency_format'], $price);
break;
case 'CNY':
return sprintf($GLOBALS['_CFG']['cprice_format'], $price);
break;
case 'EUR':
return sprintf($GLOBALS['_CFG']['aprice_format'], $price);
break;
case 'GBP':
return sprintf($GLOBALS['_CFG']['ybprice_format'], $price);
break;
case 'AUD':
return sprintf($GLOBALS['_CFG']['aoprice_format'], $price);
break;
}
}

$rate = explode(',',$GLOBALS['_CFG']['rate']); 这句是从数据库获得我们当时的参数 然后我们计算 同时返回值的时候我们用了系统设置的符号 解决问题 前台就这样搞定。
ecshop 二次开发(https://www.wendangku.net/doc/9a12975796.html,)整理。
5、有关交易 后台的操作我做简单的介绍 我们只是解决了显示问题 其实我们实质的数据还是美元 在我们提交订单的时候 我们在order_goods表加俩个

字段一个是客户选的货币方式 这样生成订单后 当
我进入我的会员中心我依然可以看到我购买人民币是多少钱 我们读取数据库的方式进行换算,另外一个字段是我们换算后的金额。当然我们之前美元的总金额都是在的 。在支付的时候 我们给贝宝付参
数 就是货币类型 。搞定。(如果有用看完就顶贴 )


---------------------------------------------------------------------------------------------------------------------------------------------------------

如何实现ecshop中把相册里每一张图片自动缩略成 商品图片大小


如何实现ecshop中把相册里每一张图片自动缩略成 商品图片大小(一)现在的ecshop 在添加新商品的时候 把上传的商品图片 剪裁成 小图片 (在前台单个商品页面的 商品图片下面的 相册图片列表图
片 , $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height'] 这个是大小) 跟 商品图片(就是单个商品页面的 商品图片 , $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']
['image_height'] 这个是大小)
然而 ecshop 现在 只是 处理 添加商品是 上传的那张 图片 (但是 相册里面的 图片 只是处理成 小图片 )

我想做一个 在相册里上传图片的时候 并处理 缩小成 小图片的时候 顺便 生成一个 商品图片 并存放在 goods_img 文件夹下

以下 是 在上传 相册图片的时候 并生成 缩略图

这个方法 是 ...\upload\admin\includes\lib_goods.php 里的方法

**
* 保存某商品的相册图片
* @param int $goods_id
* @param array $image_files
* @param array $image_descs
* @return void
*/
function handle_gallery_image($goods_id, $image_files, $image_descs)
{
/* 是否处理缩略图 */
$proc_thumb = (isset($GLOBALS['shop_id']) && $GLOBALS['shop_id'] > 0)? false : true;
foreach ($image_descs AS $key => $img_desc)
{
/* 是否成功上传 */
$flag = false;
if (isset($image_files['error']))
{
if ($image_files['error'][$key] == 0)
{
$flag = true;
}
}
else
{
if ($image_files['tmp_name'][$key] != 'none')
{
$flag = true;
}
}
if ($flag)
{
// 生成缩略图
if ($proc_thumb)
{
$thumb_url = $GLOBALS['image']->make_thumb($image_files['tmp_name'][$key], $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height']);
$thumb_url = is_string($thumb_url) ? $thumb_url : '';
}
$upload = array(
'name' => $image_files['name'][$key],
'type' => $image_files['type'][$key],
'tmp_name' => $image_files['tmp_name'][$key],
'size' => $image

_files['size'][$key],
);

if (isset($image_files['error']))
{
$upload['error'] = $image_files['error'][$key];
}
$img_original = $GLOBALS['image']->upload_image($upload);

if ($img_original === false)
{
sys_msg($GLOBALS['image']->error_msg(), 1, array(), false);
}
$img_url = $img_original;
if (!$proc_thumb)
{
$thumb_url = $img_original;
}
// 如果服务器支持GD 则添加水印
if ($proc_thumb && gd_version() > 0)
{
$pos = strpos(basename($img_original), '.');
$newname = dirname($img_original) . '/' . $GLOBALS['image']->random_filename() . substr(basename($img_original), $pos);
copy('../' . $img_original, '../' . $newname);
$img_url = $newname;
$GLOBALS['image']->add_watermark('../'.$img_url,'',$GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']);
}
//********************************************************
// 生成商品图片的缩略图 开始
//********************************************************
if ($GLOBALS['_CFG']['image_width'] != 0 || $GLOBALS['_CFG']['image_height'] != 0)
{
$goods_thumb_url = $GLOBALS['image']->make_thumb($image_files['tmp_name'][$key], $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']['image_height']);
$goods_thumb_url = is_string($goods_thumb_url) ? $goods_thumb_url : '';
$upload = array(
'name' => $image_files['name'][$key],
'type' => $image_files['type'][$key],
'tmp_name' => $image_files['tmp_name'][$key],
'size' => $image_files['size'][$key],
);

if (isset($image_files['error']))
{
$upload['error'] = $image_files['error'][$key];
}
$goods_img_original = $GLOBALS['image']->upload_image($upload);
}

if ($goods_img_original === false)
{
sys_msg($GLOBALS['image']->error_msg(), 1, array(), false);
}
$goods_img_url = $goods_img_original;
if (!$proc_thumb)
{
$goods_thumb_url = $goods_img_original;
}
// 如果服务器支持GD 则添加水印
if ($proc_thumb && gd_version() > 0)
{
$pos = strpos(basename($goods_img_original), '.');
$newname = dirname($goods_img_original) . '/' . $GLOBALS['image']->random_filename() . substr(basename($goods_img_original), $pos);

copy('../' . $goods_img_original, '../' . $newname);
$goods_img_url = $newname;
$GLOBALS['image']->add_watermark('../'.$goods_img_url,'',$GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']);
}

//********************************************************
// 生成商品图片的缩略图 结束
//********************************************************
/* 重新格式化图片名称 */
$img_original = reformat_image_name('gallery', $goods_id, $img_original, 'source');

//********************************************************
$goods_thumb_url = reformat_image_name('gallery_thumb', $goods_id, $goods_thumb_url, 'goods');
//********************************************************

$img_url = reformat_image_name('gallery', $goods_id, $img_url, 'goods');
$thumb_url = reformat_image_name('gallery_thumb', $goods_id, $thumb_url, 'thumb');
$sql = "INSERT INTO " . $GLOBALS['ecs']->table('goods_gallery') . " (goods_id, img_url, img_desc, thumb_url, img_original,goods_img) " .
"VALUES ('$goods_id', '$img_url', '$img_desc', '$thumb_url', '$img_original','$goods_thumb_url')";
$GLOBALS['db']->query($sql);
/* 不保留商品原图的时候删除原图 */
if ($proc_thumb && !$GLOBALS['_CFG']['retain_original_img'] && !empty($img_original))
{
$GLOBALS['db']->query("UPDATE " . $GLOBALS['ecs']->table('goods_gallery') . " SET img_original='' WHERE `goods_id`='{$goods_id}'");
@unlink('../' . $img_original);
}
}
}

}

goods_img 这个字段是我在 数据表 ecs_goods_gallery 表中添加的字段 用来存放 相册图片的商品缩略图的路径

* 保存某商品的相册图片
* @param int $goods_id
* @param array $image_files
* @param array $image_descs
* @return void
*/
function handle_gallery_image($goods_id, $image_files, $image_descs)
{
/* 是否处理缩略图 */
$proc_thumb = (isset($GLOBALS['shop_id']) && $GLOBALS['shop_id'] > 0)? false : true;
foreach ($image_descs AS $key => $img_desc)
{
/* 是否成功上传 */
$flag = false;
if (isset($image_files['error']))
{
if ($image_files['error'][$key] == 0)
{
$flag = true;
}
}
else
{
if ($image_files['tmp_name'][$key] != 'none')
{
$flag = true;
}
}
if ($flag)
{
// 生成缩略图
if ($proc_thumb)
{
$thumb_url = $GLOBALS['image']->make_thumb($image_files['tmp

_name'][$key], $GLOBALS['_CFG']['thumb_width'], $GLOBALS['_CFG']['thumb_height']);
$thumb_url = is_string($thumb_url) ? $thumb_url : '';
}
$upload = array(
'name' => $image_files['name'][$key],
'type' => $image_files['type'][$key],
'tmp_name' => $image_files['tmp_name'][$key],
'size' => $image_files['size'][$key],
);

if (isset($image_files['error']))
{
$upload['error'] = $image_files['error'][$key];
}
$img_original = $GLOBALS['image']->upload_image($upload);

if ($img_original === false)
{
sys_msg($GLOBALS['image']->error_msg(), 1, array(), false);
}
$img_url = $img_original;

if (!$proc_thumb)
{
$thumb_url = $img_original;
}
// 如果服务器支持GD 则添加水印
if ($proc_thumb && gd_version() > 0)
{
$pos = strpos(basename($img_original), '.');
$newname = dirname($img_original) . '/' . $GLOBALS['image']->random_filename() . substr(basename($img_original), $pos);
copy('../' . $img_original, '../' . $newname);
$img_url = $newname;
echo "";
$GLOBALS['image']->add_watermark('../'.$img_url,'',$GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']);
}
//********************************************************
// 生成商品图片的缩略图 开始
//********************************************************

if ($GLOBALS['_CFG']['image_width'] != 0 || $GLOBALS['_CFG']['image_height'] != 0)
{

$goods_thumb_url = $GLOBALS['image']->make_thumb('../'. $img_url , $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']['image_height']);
if ($goods_thumb_url === false)
{
sys_msg($image->error_msg(), 1, array(), false);
}

// 加水印
if (intval($GLOBALS['_CFG']['watermark_place']) > 0 && !empty($GLOBALS['_CFG']['watermark']))
{
if ($image->add_watermark('../'.$goods_thumb_url,'',$GLOBALS['_CFG']['watermark'], $GLOBALS['_CFG']['watermark_place'], $GLOBALS['_CFG']['watermark_alpha']) === false)
{
sys_msg($image->error_msg(), 1, array(), false);
}
}
}
//********************************************************
// 生成商品图片的缩

略图 结束
//********************************************************
/* 重新格式化图片名称 */
$img_original = reformat_image_name('gallery', $goods_id, $img_original, 'source');

//********************************************************
$goods_thumb_url = reformat_image_name('gallery_thumb', $goods_id, $goods_thumb_url, 'goods');
//********************************************************

$img_url = reformat_image_name('gallery', $goods_id, $img_url, 'goods');
$thumb_url = reformat_image_name('gallery_thumb', $goods_id, $thumb_url, 'thumb');
$sql = "INSERT INTO " . $GLOBALS['ecs']->table('goods_gallery') . " (goods_id, img_url, img_desc, thumb_url, img_original,goods_img) " .
"VALUES ('$goods_id', '$img_url', '$img_desc', '$thumb_url', '$img_original','$goods_thumb_url')";
$GLOBALS['db']->query($sql);
/* 不保留商品原图的时候删除原图 */
if ($proc_thumb && !$GLOBALS['_CFG']['retain_original_img'] && !empty($img_original))
{
$GLOBALS['db']->query("UPDATE " . $GLOBALS['ecs']->table('goods_gallery') . " SET img_original='' WHERE `goods_id`='{$goods_id}'");
@unlink('../' . $img_original);
}
}
}

}



---------------------------------------------------------------------------------------------------------------------------------------------------------
如何让ecshop首页“站内快讯”垂直滚动显示(无缝滚动)

x想要实现这个功能,将 library/new_articles.lbi 文件内容完全替换为下面代码即可:








----------------------------------------------------

-----------------------------------------------------------------------------------------------------
如何在ecshop中实现上一个,下一个的链接地址带上产品名称

修改goods.php文件里的如下代码:

/* 上一个商品下一个商品 */
$prev_gid = $db->getRow("SELECT goods_id,goods_name FROM " .$ecs->table('goods'). " WHERE cat_id=" . $goods['cat_id'] . " AND goods_id > " . $goods['goods_id'] . " AND is_on_sale =
1 AND is_alone_sale = 1 AND is_delete = 0 LIMIT 1");
if (!empty($prev_gid))
{
$prev_good['url'] = build_uri('goods', array('gid' => $prev_gid['goods_id']),$prev_gid['goods_name']);
$smarty->assign('prev_good', $prev_good);//上一个商品
}

$next_gid = $db->getone("SELECT max(goods_id) FROM " . $ecs->table('goods') . " WHERE cat_id=".$goods['cat_id']." AND goods_id < ".$goods['goods_id'] . " AND is_on_sale = 1 AND
is_alone_sale = 1 AND is_delete = 0");
if (!empty($next_gid))
{
$next_good['goods_name'] = $db -> getOne("select goods_name from ".$ecs->table('goods')." where goods_id =".$next_gid);
$next_good['url'] = build_uri('goods', array('gid' => $next_gid),$next_good['goods_name']);
$smarty->assign('next_good', $next_good);//下一个商品
更多ecshop二次开发


---------------------------------------------------------------------------------------------------------------------------------------------------------
如何进行ecshop二次开发

保存用户购物车数据

ECSHOP的购物车数据,是以Session 方式存储在数据库里,并在Session结束后 ,Distroy 掉,解决方法是:

1.购物车内容读取方式. 更改登陆后购物车获取条件 "Session 单独方式"为 Session +用户名 ,该修改位于Lib_order 下 function get_cart_goods();


2. 购物车内容记录方式,未登陆方式依然是Session , 用户登陆后,自动UPdate Cart 一次, 将同一UserID下购物车内数据不是当前Session的Update到当前Session , 并将当前Session 下UserID为0的部
分(未登陆情况下,Userid是0),UpdateID到当前UserID ,该修改位于 Flow.php 下面function flow_update_cart($arr)

3.更改退出时,自动 Clear Cart的部分,将Distroy 当前Session 的内容,更改为Distroy 当前Session 下 User ID为0的部分。 该修改位于:Includes/cls_session.php , function destroy_session() 部分


说明:这种情况下就是游客关闭浏览器后,购物车清空, 注册用户购物车永久保存, 可能会对服务器造成轻微压力,主要取决于用户的数量, 如果数量较多数据服务器压力较大,可以通过程序,自动
清理超过一定时间段未登陆的User Cart (或者是额外增加一个数据,来标示加入购物车的时间,根据此时间判断是否自
动清理).

以上就是ecshop二次开发的思路,如果看完这

篇文章还有不明白的地方,可以加我的qq大家一起交流78000672

---------------------------------------------------------------------------------------------------------------------------------------------------------

如何在ecshop中实现三级菜单

实现此项功能,主要是修改模板文件:category_tree.lbi

{assign var="isshow" value=0}
{assign var="mylevel" value=0}

{$https://www.wendangku.net/doc/9a12975796.html,|escape:html}




{if $mychild.id eq $child.id}
{assign var="isshow" value=1}
{assign var="mylevel" value=$mychild.level}
{$https://www.wendangku.net/doc/9a12975796.html,|escape:html}

{else}
{if $mychild.level le $mylevel}
{assign var="isshow" value=0}
{/if}
{if $isshow eq 1}
{$https://www.wendangku.net/doc/9a12975796.html,|escape:html}

{/if}
{/if}





---------------------------------------------------------------------------------------------------------------------------------------------------------
如何在ECShop中增加客户付款时发送客服邮件的功能

要实现这个功能,就要修改ECshop的程序文件:\includes \lib_payment.php,打开该文件,找到166行左右,在”如果需要,发短信”的代码下面,插入以下的代码:


/* 发送客服邮件 */
if ($pay_status){
// 设置邮件的发件人姓名和Email地址:
$service_mail['email'] = $GLOBALS['_CFG']['service_email']; // 自动读取客服邮件地址;
$service_mail['sender'] = $GLOBALS['_CFG']['shop_name']; // 自动读取网店名称;
// 订单的基本情况:
$sql = “SELECT pay_status,shipping_name,shipping_fee,
pay_name,consignee,address,zipcode,tel,money_paid
FROM “.$GLOBALS['ecs']->table(’order_info’).”
WHERE order_id = $order_id “;
$order_info = $GLOBALS['db']->getRow($sql);
if ($order_info['pay_status'] == PS_PAYED) $service_mail['status']=’已付款’;
if ($order_info['pay_status'] == PS_PAYING) $service_mail['status']=’已付款到支付宝’;// 货款暂存于支付宝的状态;
date_default_timezone_set(’PRC’);
$service_mail['subject'] = “订单 $order_sn {$service_mail['status']}。”; // 定义邮件的主题;
// 以下是定义邮件的主要内容,可以根据自己的实际情况调整:
$service_mail['content'] = date(’Y-m-d H:i’).” 订单 $order_sn {$service_mail['status']},可以开始发货。 \r\n”;
if ($note){
$service_

mail['content'] .= ‘付款留言:’.$note.”\r\n”;
}
$service_mail['content'] .= “订单的详细情况:\r\n”;
$service_mail['content'] .= “总金额:{$order_info['money_paid']} 元;\r\n”;
$service_mail['content'] .= “配送方式:{$order_info['shipping_name']}(配送费: {$order_info['shipping_fee']})\r\n”;
$service_mail['content'] .= “付款方式:{$order_info['pay_name']}({$service_mail['status']})\r\n”;
$service_mail['content'] .= “收货人:{$order_info['consignee']}\r\n”;
if ($order_info['zipcode']) $order_info['zipcode'] = ” 邮编:{$order_info['zipcode']}”; else $order_info['zipcode'] = ”;
$service_mail['content'] .= “收货人地址:{$order_info['address']} {$order_info['zipcode']}\r\n”;
$service_mail['content'] .= “收货人电话:{$order_info['tel']}\r\n\r\n”;
// 生成商品清单:
$service_mail['content'] .= “订购商品清单:\r\n”;
$sql = “SELECT goods_sn,goods_name,goods_number,goods_price
FROM “.$GLOBALS['ecs']->table(’order_goods’).” og, “.$GLOBALS['ecs']->table(’order_info’).” oi
WHERE og.order_id = oi.order_id
AND oi.order_id = $order_id”;
$res = $GLOBALS['db']->getAll($sql);
foreach ($res as $value){
$service_mail['content'] .= “货号:{$value['goods_sn']}; \t商品:{$value['goods_name']}; \t数量:{$value['goods_number']}; \r\n”;
}
// 发送邮件:
send_mail($service_mail['sender'], $service_mail['email'], $service_mail['subject'], $service_mail['content'], 0);
}如果您看完这篇文章还有不明白的地方可以资讯qq78000672或者浏览ecshop二次开发
---------------------------------------------------------------------------------------------------------------------------------------------------------

后台商品列表显缩略图方法

修改一:admin\includes\lib_goods.php (可能是781行)
$sql = "SELECT goods_id, goods_name, goods_sn, shop_price, goods_thumb, is_on_sale, is_best, is_new, is_hot, goods_number, integral, " .
加多红色部分
修改二:admin\templates\goods_list.htm
顶端加以下样式:


在以地方加多红色部分(可能是41行)


{$goods.goods_name|escape:html}


如果看完这篇文章还没有清楚可以点击这里ecshop 二次开发
----------------------------------------------------------------------

-----------------------------------------------------------------------------------

如何在ecshop中增加在线询价功能

第一步,打开goods.dwt 在商品详细页的价格后面增加



在线询价

第二步,打开 user_clips.dwt ,替换相关代码(注,这些说明可以按照自己的产品特性加以修改)






{if $order_info}




{else}




{/if}

















{$lang.order_number}
{$order_info.order_sn}


询价类型:
模板询价

定制询价
{$lang.message_title}: * 请填写模板名称 或 标明定制询价
详细信息:



* 请填写希望成交的金额以及您的真实联系方式,以便于我们的工作人员及时与你取得联系,
您也可以经常关注我们网站获得最新信息。



{$lang.img_type_tips}

pan style="color:#F00">如果你曾经与我们合作过可以在详细信息中阐明,我们将酌情予以优惠。




第三步:打开library/user_menu.lbi

修改相关代码





在线询价

这样整一个在线询价功能就实现了,而且这个询价要在注册之后才可进行,又增加了会员注册量,真是一举两得。
其实ECSHOP的功能还是很强大的,大家适当的进行ecshop二次开发就可以达到一些想象不到的效果,欢迎大家探讨。
---------------------------------------------------------------------------------------------------------------------------------------------------------

如何让ecshop商品促销的时间精确到分钟

找到admin/tempate/good_info.htm文件:

改为




改为


然后修改 admin/goods.php
把 $goods['promote_start_date'] = local_date('Y-m-d', $goods['promote_start_date']);
$goods['promote_end_date'] = local_date('Y-m-d', $goods['promote_end_date']);
改为
$goods['promote_start_date'] = local_date('Y-m-d H:i', $goods['promote_start_date']);
$goods['promote_end_date'] = local_date('Y-m-d H:i', $goods['promote_end_date']);
---------------------------------------------------------------------------------------------------------------------------------------------------------

如何在ecshop首页添加最新已发货订单显示

前面已经讲过ecshop二次开发的思路,下面我们就实际操作下:在 lib_insert.php文件里面加入一下函数
function insert_index_get_order_new()
{
$sql = 'SELECT order_sn,invoice_no FROM ' . $GLOBALS['ecs']->table('order_info').'where shipping_status='. SS_SHIPPED .' ORDER BY shipping_time DESC LIMIT 10'; //这里需要显示多少就改
变‘10’这个值
$all = $GLOBALS['db']->getAll($sql);
$GLOBALS['smarty']->assign('order_new', $all);
$val = $GLOBALS['smarty']->fetch('library/temp.lbi');
return $val;
}

$smarty->assign('order_new', index_get_o

rder_new()); // 新订单滚动

增加两个lib文件
temp_insert.lbi
文件内容

{insert name='index_get_order_new'}

temp.lbi
文件内容(页面展示的模板)











{$order.order_sn}{$order.invoice_no}






index.dwt 如果加在首页就改这个模板
在需要的地方加入一下代码
{insert name='index_get_order_new'}
然后页面上应该就可以显示出来
---------------------------------------------------------------------------------------------------------------------------------------------------------

如何给ecshop添加可折叠和双排的分类列表

对于ecshop二次开发----添加可折叠列表的功能其实大部分都是对模板做些调整,加上一些js脚本就可以了。我们分两步来完成,一是调整模板生成方便我们js操作的html结构,二是书写js脚本,完成功
能。
一、调整模板:
我们这次要调整的还是category_tree.lbi文件,以前生成的分类是放到
里面,部分div的概念,我们用js 对
这些标签的操作没有用
来的方便,所以我们书写下面代码,把我们一级分
类做成一个”id-header”的div,把分类下的二级分类放到一个”id-centent”下的div里面。这样调整后我们就可以通过js动态的改变二级分类div的现实不显示来完成菜单的折叠功能了。当然在改变之前我们
要给分类前面加入一个img来显示折叠的+和-号,代码如下:
{$https://www.wendangku.net/doc/9a12975796.html,|escape:html} {$https://www.wendangku.net/doc/9a12975796.html,|escape:html}


下面给出模板调整后的代码:
style="display:block;float:left;background-color:#ffffff;">
{$https://www.wendangku.net/doc/9a12975796.html,|escape:html}
{$https://www.wendangku.net/doc/9a12975796.html,|e