商品详情页面属性价格显示其对应价格

ecshop默认的商品属性显示的是加多少钱

第一步:在lib_goods.php中找到

function get_goods_properties 方法

将下面的get_goods_properties方法覆盖掉原来的get_goods_properties方法/*** 获得商品的属性和规格** @access public* @param integer $goods_id* @return array*///yyy修改startfunction get_goods_properties($goods_id , $shop_price=0)//yyy修改end{ /* 对属性进行重新排序和分组 */ $sql = "SELECT attr_group ". "FROM " . $GLOBALS[‘ecs’]->table(‘goods_type’) . " AS gt, " . $GLOBALS[‘ecs’]->table(‘goods’) . " AS g ". "WHERE g.goods_id=’$goods_id’ AND gt.cat_id=g.goods_type"; $grp = $GLOBALS[‘db’]->getOne($sql);

if (!empty($grp)) { $groups = explode("\n", strtr($grp, "\r", ”)); }

/* 获得商品的规格 */ $sql = "SELECT a.attr_id, a.attr_name, a.attr_group, a.is_linked, a.attr_type, ". "g.goods_attr_id, g.attr_value, g.attr_price " . ‘FROM ‘ . $GLOBALS[‘ecs’]->table(‘goods_attr’) . ‘ AS g ‘ . ‘LEFT JOIN ‘ . $GLOBALS[‘ecs’]->table(‘attribute’) . ‘ AS a ON a.attr_id = g.attr_id ‘ . "WHERE g.goods_id = ‘$goods_id’ " . ‘ORDER BY a.sort_order, g.attr_price, g.goods_attr_id’; $res = $GLOBALS[‘db’]->getAll($sql);

$arr[‘pro’] = array(); // 属性 $arr[‘spe’] = array(); // 规格 $arr[‘lnk’] = array(); // 关联的属性

foreach ($res AS $row) { $row[‘attr_value’] = str_replace("\n", ‘<br />’, $row[‘attr_value’]);

if ($row[‘attr_type’] == 0) { $group = (isset($groups[$row[‘attr_group’]])) ? $groups[$row[‘attr_group’]] : $GLOBALS[‘_LANG’][‘goods_attr’];

$arr[‘pro’][$group][$row[‘attr_id’]][‘name’] = $row[‘attr_name’]; $arr[‘pro’][$group][$row[‘attr_id’]][‘value’] = $row[‘attr_value’]; } else { $arr[‘spe’][$row[‘attr_id’]][‘attr_type’] = $row[‘attr_type’]; $arr[‘spe’][$row[‘attr_id’]][‘name’] = $row[‘attr_name’];//yyy修改start $arr[‘spe’][$row[‘attr_id’]][‘values’][] = array( ‘label’ => $row[‘attr_value’], ‘price’ => $row[‘attr_price’], ‘format_price’ => price_format(abs($row[‘attr_price’]) + $shop_price, false),’id’ => $row[‘goods_attr_id’]);//yyy修改end }

仿佛松树就是一位威风的将军,守护着国家的国民。

商品详情页面属性价格显示其对应价格

相关文章:

你感兴趣的文章:

标签云: