首页 > 网站 > 建站经验 > 正文

ecshop历史浏览、购买了该商品的人还买了、相关联产品模块增加“市场价格”

2024-04-25 20:44:04
字体:
来源:转载
供稿:网友

一、历史浏览模块增加市场价格:

打开include/lin_insert.php 直接替换下面这段函数

/**

* 调用浏览历史

*

* @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, market_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['market_price'] = price_format($row['market_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 />'.原价:.$goods['market_price'].'<br />'.现价:.'<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;

}

二、购买过该商品的朋友还购买了模块增加市场价格:

打开goods.php 直接替换以下函数

/**

* 获得购买过该商品的人还买过的商品

*

* @access public

* @param integer $goods_id

* @return array

*/

function get_also_bought($goods_id)

{

$sql = 'SELECT COUNT(b.goods_id ) AS num, g.goods_id, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price, g.market_price, g.promote_price, g.promote_start_date, g.promote_end_date ' .

'FROM ' . $GLOBALS['ecs']->table('order_goods') . ' AS a ' .

'LEFT JOIN ' . $GLOBALS['ecs']->table('order_goods') . ' AS b ON b.order_id = a.order_id ' .

'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . ' AS g ON g.goods_id = b.goods_id ' .

"WHERE a.goods_id = '$goods_id' AND b.goods_id <> '$goods_id' AND g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 " .

'GROUP BY b.goods_id ' .

'ORDER BY num DESC ' .

'LIMIT ' . $GLOBALS['_CFG']['bought_goods'];

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

$key = 0;

$arr = array();

while ($row = $GLOBALS['db']->fetchRow($res))

{

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

$arr[$key]['goods_name'] = $row['goods_name'];

$arr[$key]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?

sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];

$arr[$key]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);

$arr[$key]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);

$arr[$key]['shop_price'] = price_format($row['shop_price']);

$arr[$key]['market_price'] = price_format($row['market_price']);

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

if ($row['promote_price'] > 0)

{

$arr[$key]['promote_price'] = bargain_price($row['promote_price'], $row['promote_start_date'], $row['promote_end_date']);

$arr[$key]['formated_promote_price'] = price_format($arr[$key]['promote_price']);

}

else

{

$arr[$key]['promote_price'] = 0;

}

$key++;

}

return $arr;

}

然后再模板文件bought_goods.lbi 中加上

原价:{$bought_goods_data.market_price}

三、相关联商品模块增加市场价格:

直接打开模板文件goods_related.lbi

插入:

原价:{$releated_goods_data.market_price}

即可

以上就是本文章的内容,希望对大家有所帮助

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表