官方微博: 腾讯  
首页 > ECSHOP教程 > ECSHOP模板教程 > ECSHOP购买流程页修改 > ecshop购物车结算中心页面显示商品图片方法

ecshop购物车结算中心页面显示商品图片方法

ECSHOP教程 / ecshop 教程网(www.ecshop119.com) 2013-05-21

ECshop在购物结算中心页面显示出商品图片的方法!

做购物流程页面时要求显示商品图,EC系统默认在购物车页面是可以显示商品图片的,但是点结算后到结算中心页面你会发现只有商品名称,没有商品图如 果我们在EC的购物流程相关文件对它的系统函数跟踪一下就会发现checkout步骤时根本没有从数据库中调出缩略图,下面把方法与大家共享,希望能给大 家一点帮助

步骤1:

打开订单函数库文件lib_order.php 位于includes目录下

搜索

/**

* 取得购物车商品

* @param int $type 类型:默认普通商品

* @return array 购物车商品数组

*/

大概在852行左右,函数原来是

 

function cart_goods($type = CART_GENERAL_GOODS)

{

$sql = "SELECT rec_id, user_id, goods_id, goods_name, goods_sn, goods_number, " .

"market_price, goods_price, goods_attr, is_real, extension_code, parent_id, is_gift, is_shipping, " .

"goods_price * goods_number AS subtotal " .

"FROM " . $GLOBALS['ecs']->table('cart') .

" WHERE session_id = '" . SESS_ID . "' " .

"AND rec_type = '$type'";

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

/* 格式化价格及礼包商品 */

foreach ($arr as $key => $value)

{

$arr[$key]['formated_market_price'] = price_format($value['market_price'], false);

$arr[$key]['formated_goods_price'] = price_format($value['goods_price'], false);

$arr[$key]['formated_subtotal'] = price_format($value['subtotal'], false);

if ($value['extension_code'] == 'package_buy')

{

$arr[$key]['package_goods_list'] = get_package_goods($value['goods_id']);

}

}

return $arr;

}

将它替换为

 

function cart_goods($type = CART_GENERAL_GOODS)

{

$sql = "SELECT c.rec_id, c.user_id, c.goods_id, c.goods_name, g.goods_thumb,c.goods_sn, c.goods_number, " .

"c.market_price, c.goods_price, c.goods_attr, c.is_real, c.extension_code, c.parent_id, c.is_gift, c.is_shipping, " .

"c.goods_price * c.goods_number AS subtotal " .

"FROM " . $GLOBALS['ecs']->table('cart') . ' AS c ' .

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

" WHERE session_id = '" . SESS_ID . "' " .

"AND rec_type = '$type'";

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

/* 格式化价格及礼包商品 */

foreach ($arr as $key => $value)

{

$arr[$key]['formated_market_price'] = price_format($value['market_price'], false);

$arr[$key]['formated_goods_price'] = price_format($value['goods_price'], false);

$arr[$key]['formated_subtotal'] = price_format($value['subtotal'], false);

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

if ($value['extension_code'] == 'package_buy')

{

$arr[$key]['package_goods_list'] = get_package_goods($value['goods_id']);

}

}

return $arr;

}

修改的作用是把cart表和goods表相连,取出goods_thumb缩略图,然后用get_image_path函数调出缩略图的地址

步骤2:

下面打开ecshop模板文件flow.dwt 搜索
<!-- {if $step eq "checkout"} 开始订单确认界面 -->

在这个下面找到
<!-- {foreach from=$goods_list item=goods} -->

<tr>

<td bgcolor="#ffffff">

<!-- {if $goods.goods_id gt 0 && $goods.extension_code eq 'package_buy'} -->

</td>

</tr>

在它的下面加入

<img src="{$goods.goods_thumb}" border="0" title="{$goods.goods_name|escape:html}" />

这个就是调出商品的缩略图了,OK,完工!

PS:如果大家想改下缩略图的大小,可以用以下代码,width是宽度,height是高度,可以自己调

<img src="{$goods.goods_thumb}" border="0" title="{$goods.goods_name|escape:html}" width="50px" height="50px"/>

转载请注明:ECshop119模板屋-ECshop教程网(全国最专业的ECSHOP插件制作商-专业ECSHOP二次开发)

帮助目录

在线反馈

可以将问题或建议反馈给我们。

提交在线反馈

与网友交流ECSHOP开发修改。

加入QQ群交流