ecshop浏览商品历史记录调用
时间:2023年06月02日
/来源:网络
/编辑:佚名
ecshop浏览商品历史记录调用
goods.php
/*记录浏览历史*/
// var_dump($_COOKIE[ 'ECS'][ 'history ']);
// array(5){ [0]=> string(2) "17”[1]=〉string(2)“23”[2]=〉 string(2) “22” [3]=) string(2) “28” [4]=)string(2) "}
if ( !empty($_COOKIE[ "ECS" ][ "history ' ]))
{
$history = explode( ' ,', $_COOKIE[ 'ECS'][ 'history']);
// var_dump( $history);
array_unshift($history,$goods_id);
$history = array_unique($history) ;
// var_dump( $history);
while (count($history) >5)
{
}
// var_dump(("ECS[history]" );
// string(12) "Ecs[history]”
setcookie('ECs[history]' , implode( ' , ' , $history), gmtime() + 3600 * 24* 30);
}
else
{
setcookie('ECS[history]', $goods_id, gmtime() + 3600* 24* 30);
}
2、lib_insert.php中的方法function insert_history()
/**
* 调用浏览历史
*
* @access public
* @return string
*/
function insert_history()
{
$str = '';
if (!empty($_COOKIE['ECS']['history']))
{
$where = db_create_in($_COOKIE['ECS']['history'], 'goods_id');
$sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM ' . $GLOBALS['ecs']->table('goods') .
" WHERE $where AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0";
$query = $GLOBALS['db']->query($sql);
$res = array();
while ($row = $GLOBALS['db']->fetch_array($query))
{
$goods['goods_id'] = $row['goods_id'];
$goods['goods_name'] = $row['goods_name'];
$goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$goods['shop_price'] = price_format($row['shop_price']);
$goods['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
$str.='<ul class="clearfix"><li class="goodsimg"><a href="'.$goods['url'].'" target="_blank"><img src="'.$goods['goods_thumb'].'" alt="'.$goods['goods_name'].'" class="B_blue" /></a></li><li><a href="'.$goods['url'].'" target="_blank" title="'.$goods['goods_name'].'">'.$goods['short_name'].'</a><br />'.$GLOBALS['_LANG']['shop_price'].'<font class="f1">'.$goods['shop_price'].'</font><br /></li></ul>';
}
$str .= '<ul id="clear_history"><a onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . '</a></ul>';
}
return $str;
}
3、历史记录模板history.lbi
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div class="box" id='history_div'>
<div class="box_1">
<h3><span>{$lang.view_history}</l span></ h3>
<div class="boxcenterList clearfix" id='history_list'>iinsert name='history'}
</div>
</ divl</ div>
<div class="blank5"></ div>
<script type="text/javascript">
if (document.getElementById ('history_list' ).innerHTML.replace(/\s/g, '' ).length<1){
document.getElementById ( ' history_div' ).style.display='none' ;
document.getElementById ( ' history_div' ).style.display='block' ;
function clear_history()
jax.call ( 'user.php','act=clear_history' ,clear_history_Response,'GET','TEXT',1,1);
function clear_history_Response (res)
document.getElementById ( 'history_list ' ).innerHTMI= '{$lang.no_history} ' ;
</ script>
goods.php
/*记录浏览历史*/
// var_dump($_COOKIE[ 'ECS'][ 'history ']);
// array(5){ [0]=> string(2) "17”[1]=〉string(2)“23”[2]=〉 string(2) “22” [3]=) string(2) “28” [4]=)string(2) "}
if ( !empty($_COOKIE[ "ECS" ][ "history ' ]))
{
$history = explode( ' ,', $_COOKIE[ 'ECS'][ 'history']);
// var_dump( $history);
array_unshift($history,$goods_id);
$history = array_unique($history) ;
// var_dump( $history);
while (count($history) >5)
{
}
// var_dump(("ECS[history]" );
// string(12) "Ecs[history]”
setcookie('ECs[history]' , implode( ' , ' , $history), gmtime() + 3600 * 24* 30);
}
else
{
setcookie('ECS[history]', $goods_id, gmtime() + 3600* 24* 30);
}
2、lib_insert.php中的方法function insert_history()
/**
* 调用浏览历史
*
* @access public
* @return string
*/
function insert_history()
{
$str = '';
if (!empty($_COOKIE['ECS']['history']))
{
$where = db_create_in($_COOKIE['ECS']['history'], 'goods_id');
$sql = 'SELECT goods_id, goods_name, goods_thumb, shop_price FROM ' . $GLOBALS['ecs']->table('goods') .
" WHERE $where AND is_on_sale = 1 AND is_alone_sale = 1 AND is_delete = 0";
$query = $GLOBALS['db']->query($sql);
$res = array();
while ($row = $GLOBALS['db']->fetch_array($query))
{
$goods['goods_id'] = $row['goods_id'];
$goods['goods_name'] = $row['goods_name'];
$goods['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ? sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];
$goods['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$goods['shop_price'] = price_format($row['shop_price']);
$goods['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
$str.='<ul class="clearfix"><li class="goodsimg"><a href="'.$goods['url'].'" target="_blank"><img src="'.$goods['goods_thumb'].'" alt="'.$goods['goods_name'].'" class="B_blue" /></a></li><li><a href="'.$goods['url'].'" target="_blank" title="'.$goods['goods_name'].'">'.$goods['short_name'].'</a><br />'.$GLOBALS['_LANG']['shop_price'].'<font class="f1">'.$goods['shop_price'].'</font><br /></li></ul>';
}
$str .= '<ul id="clear_history"><a onclick="clear_history()">' . $GLOBALS['_LANG']['clear_history'] . '</a></ul>';
}
return $str;
}
3、历史记录模板history.lbi
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div class="box" id='history_div'>
<div class="box_1">
<h3><span>{$lang.view_history}</l span></ h3>
<div class="boxcenterList clearfix" id='history_list'>iinsert name='history'}
</div>
</ divl</ div>
<div class="blank5"></ div>
<script type="text/javascript">
if (document.getElementById ('history_list' ).innerHTML.replace(/\s/g, '' ).length<1){
document.getElementById ( ' history_div' ).style.display='none' ;
document.getElementById ( ' history_div' ).style.display='block' ;
function clear_history()
jax.call ( 'user.php','act=clear_history' ,clear_history_Response,'GET','TEXT',1,1);
function clear_history_Response (res)
document.getElementById ( 'history_list ' ).innerHTMI= '{$lang.no_history} ' ;
</ script>
新闻资讯 更多
热门文章
- 178Moban源码谈谈免费源码与收费源码的区别
- 2帝国CMS忘记后台登陆用户名、密码、认证码的解决方法
- 3帝国CMS(EmpireCMS) v7.5后台任意代码执行漏洞及具体修复方法
- 4帝国CMS和WordPress 哪个好?哪个适合建站?
- 5如何解决Discuz的密码错误次数过多请15分钟后登陆的问题
- 6帝国cms灵动标签取得内容和栏目链接地址
- 7emlog pro 注册码“开心”教程(如果有一天,emlog官方版 或者 emlog免费版 跑路了,那用户怎么办?)
- 8织梦CMS在nginx下设置伪静态方法(附nginx伪静态规则)
- 9帝国cms后台登录出现”您还未登录”怎么解决?
- 10帝国cms7.5忘记登录密码 和忘记登录认证码以及多次登录 失败被锁定解决办法