如图所示: ecshop本身只有在购物车中涉及到折扣,我们要的不是那种,是单一商品的价比。 如下操作: 在include目录中,找到lib_goods.php,在最后增加如下函数: function get_zhekou($goods_id){$sql = select shop_price,market_price from . $GLOBALS['e
如图所示:
ecshop本身只有在购物车中涉及到折扣,我们要的不是那种,是单一商品的价格比。
如下操作:
在include目录中,找到lib_goods.php,在最后增加如下函数:
function get_zhekou($goods_id) { $sql = "select shop_price,market_price from " . $GLOBALS['ecs']->table('goods') . " WHERE goods_id = " . $goods_id . " " ; $res = $GLOBALS['db']->query($sql); while ($row = $GLOBALS['db']->fetchRow($res)) { $a = $row['shop_price'];//商品售价 $b = $row['market_price'];//商品市场价 } $c = 10; if($b0) { $c = $a/$b; } else { } //return number_format($c,2)*10; return number_format($c,2)*10; }
$goods[$idx]['url'] = build_uri('goods', array('gid' => $row['goods_id']), $row['goods_name']);
$goods[$idx]['goods_zhekou']= get_zhekou($row['goods_id']);
比如:
{if $goods.goods_zhekou} {$goods.goods_zhekou} {else} 0 {/if}折
完成,简单吧。