ECSHOP购物车结算提交订单页面显示商品缩略图
ECSHOP系统,在购物车页面,是可以显示商品缩略图的,但是ecshop在订单提交的页面却不支持显示缩略图,好在ECSHOP是开源的,通过以下方法可以实现:(修改前备份文件,以免出错无法挽回)
第一步、打开 include/lib_order.php 文件,查找以下代码:
/** * 取得购物车商品 * @param int $type 类型:默认普通商品 * @return array 购物车商品数组 */ 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; }
替换为以下代码(注意备份):
/** * 取得购物车商品 * @param int $type 类型:默认普通商品 * @return array 购物车商品数组 */ 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) { /* LONGHTML 增加是否在购物车里显示商品图 */ if (($GLOBALS['_CFG']['show_goods_in_cart'] == "2" || $GLOBALS['_CFG']['show_goods_in_cart'] == "3") && $row['extension_code'] != 'package_buy') { $goods_thumb = $GLOBALS['db']->getOne("SELECT `goods_thumb` FROM " . $GLOBALS['ecs']->table('goods') . " WHERE `goods_id`=".$arr[$key]['goods_id']); $arr[$key]['goods_thumb'] = get_image_path($arr[$key]['goods_id'], $goods_thumb, true); } // END $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; }
第二步:修改 themes/XXX/flow.dwt 文件; “XXX”为所选择的模板目录。
查找:
<!-- {if $step eq "checkout"} 开始订单确认界面 -->
<form action="flow.php" method="post" name="theForm" id="theForm" onsubmit="return checkOrderForm(this)">
<script type="text/javascript">
var flow_no_payment = "{$lang.flow_no_payment}";
var flow_no_shipping = "{$lang.flow_no_shipping}";
</script>
<div class="flowBox">
<h6><span>{$lang.goods_list}</span><!--{if $allow_edit_cart} --><a href="flow.php" class="f6">{$lang.modify}</a><!--{/if} --></h6>
<table width="99%" align="center" border="0" cellpadding="5" cellspacing="1" bgcolor="#dddddd">
<tr>
<th bgcolor="#ffffff">{$lang.goods_name}</th>
<th bgcolor="#ffffff">{$lang.goods_attr}</th>
<!-- {if $show_marketprice} -->
<th bgcolor="#ffffff">{$lang.market_prices}</th>
<!-- {/if} -->
<th bgcolor="#ffffff">{if $gb_deposit}{$lang.deposit}{else}{$lang.shop_prices}{/if}</th>
<th bgcolor="#ffffff">{$lang.number}</th>
<th bgcolor="#ffffff">{$lang.subtotal}</th>
</tr>
<!-- {foreach from=$goods_list item=goods} -->
<tr>
<td bgcolor="#ffffff">
<!-- {if $goods.goods_id gt 0 && $goods.extension_code eq 'package_buy'} -->
<a href="javascript:void(0)" onclick="setSuitShow({$goods.goods_id})" class="f6">{$goods.goods_name}<span style="color:#FF0000;">({$lang.remark_package})</span></a>
<div id="suit_{$goods.goods_id}" style="display:none">
<!-- {foreach from=$goods.package_goods_list item=package_goods_list} -->
<a href="goods.php?id={$package_goods_list.goods_id}" target="_blank" class="f6">{$package_goods_list.goods_name}</a><br />
<!-- {/foreach} -->
</div>
<!-- { else } -->
<a href="goods.php?id={$goods.goods_id}" target="_blank" class="f6">{$goods.goods_name}</a>
<!-- {if $goods.parent_id > 0} -->
<span style="color:#FF0000">({$lang.accessories})</span>
<!-- {elseif $goods.is_gift} -->
<span style="color:#FF0000">({$lang.largess})</span>
<!-- {/if} -->
<!-- {/if} -->
<!-- {if $goods.is_shipping} -->(<span style="color:#FF0000">{$lang.free_goods}</span>)<!-- {/if} -->
</td>
<td bgcolor="#ffffff">{$goods.goods_attr|nl2br}</td>
<!-- {if $show_marketprice} -->
<td align="right" bgcolor="#ffffff">{$goods.formated_market_price}</td>
<!-- {/if} -->
<td bgcolor="#ffffff" align="right">{$goods.formated_goods_price}</td>
<td bgcolor="#ffffff" align="right">{$goods.goods_number}</td>
<td bgcolor="#ffffff" align="right">{$goods.formated_subtotal}</td>
</tr>
<!-- {/foreach} -->
<!-- {if !$gb_deposit} 团购且有保证金时不显示 -->
<tr>
<td bgcolor="#ffffff" colspan="7">
<!-- {if $discount gt 0} -->{$your_discount}<br /><!-- {/if} -->
{$shopping_money}<!-- {if $show_marketprice} -->,{$market_price_desc}<!--{/if}-->
</td>
</tr>
<!-- {/if} -->
</table>
替换为:
<!-- {if $step eq "checkout"} 开始订单确认界面 -->
<form action="flow.php" method="post" name="theForm" id="theForm" onsubmit="return checkOrderForm(this)">
<script type="text/javascript">
var flow_no_payment = "{$lang.flow_no_payment}";
var flow_no_shipping = "{$lang.flow_no_shipping}";
</script>
<div class="flowBox">
<h6><span>{$lang.goods_list}</span><!--{if $allow_edit_cart} --><a href="flow.php" class="f6">{$lang.modify}</a><!--{/if} --></h6>
<table width="99%" align="center" border="0" cellpadding="5" cellspacing="1" bgcolor="#dddddd">
<tr>
<th bgcolor="#ffffff">商品图片</th>
<th bgcolor="#ffffff">{$lang.goods_name}</th>
<th bgcolor="#ffffff">{$lang.goods_attr}</th>
<!-- {if $show_marketprice} -->
<th bgcolor="#ffffff">{$lang.market_prices}</th>
<!-- {/if} -->
<th bgcolor="#ffffff">{if $gb_deposit}{$lang.deposit}{else}{$lang.shop_prices}{/if}</th>
<th bgcolor="#ffffff">{$lang.number}</th>
<th bgcolor="#ffffff">{$lang.subtotal}</th>
</tr>
<!-- {foreach from=$goods_list item=goods} -->
<tr>
<td bgcolor="#ffffff" align="center"><img style="width:60px; border:1px solid #e3e3e3" src="{$goods.goods_thumb}" border="1" title="{$goods.goods_name|escape:html}"/></td>
<td bgcolor="#ffffff">
<!-- {if $goods.goods_id gt 0 && $goods.extension_code eq 'package_buy'} -->
<a href="javascript:void(0)" onclick="setSuitShow({$goods.goods_id})" class="f6">{$goods.goods_name}<span style="color:#FF0000;">({$lang.remark_package})</span></a>
<div id="suit_{$goods.goods_id}" style="display:none">
<!-- {foreach from=$goods.package_goods_list item=package_goods_list} -->
<a href="goods.php?id={$package_goods_list.goods_id}" target="_blank" class="f6">{$package_goods_list.goods_name}</a><br />
<!-- {/foreach} -->
</div>
<!-- { else } -->
<a href="goods.php?id={$goods.goods_id}" target="_blank" class="f6">{$goods.goods_name}</a>
<!-- {if $goods.parent_id > 0} -->
<span style="color:#FF0000">({$lang.accessories})</span>
<!-- {elseif $goods.is_gift} -->
<span style="color:#FF0000">({$lang.largess})</span>
<!-- {/if} -->
<!-- {/if} -->
<!-- {if $goods.is_shipping} -->(<span style="color:#FF0000">{$lang.free_goods}</span>)<!-- {/if} -->
</td>
<td bgcolor="#ffffff">{$goods.goods_attr|nl2br}</td>
<!-- {if $show_marketprice} -->
<td align="right" bgcolor="#ffffff">{$goods.formated_market_price}</td>
<!-- {/if} -->
<td bgcolor="#ffffff" align="right">{$goods.formated_goods_price}</td>
<td bgcolor="#ffffff" align="right">{$goods.goods_number}</td>
<td bgcolor="#ffffff" align="right">{$goods.formated_subtotal}</td>
</tr>
<!-- {/foreach} -->
<!-- {if !$gb_deposit} 团购且有保证金时不显示 -->
<tr>
<td bgcolor="#ffffff" colspan="7">
<!-- {if $discount gt 0} -->{$your_discount}<br /><!-- {/if} -->
{$shopping_money}<!-- {if $show_marketprice} -->,{$market_price_desc}<!--{/if}-->
</td>
</tr>
<!-- {/if} -->
</table>
第二步也可以不用这样替换,你可以自己使用以下商品图片调用代码,在自己想要显示的位置插入代码就行了:
<img src="{$goods.goods_thumb}" border="0" title="{$goods.goods_name|escape:html}" />
后台刷新缓存就可以了
原文链接:https://www.qiquanji.com/post/8501.html
本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。