广州传奇网络

地址:广州市天河区东圃大马路富华楼C座

电话:13808825895

邮箱:gz020wbs@163.com

QQ:1564443073

网址:http://www.020wbs.com/

首页 > 二次开发Ecshop二次开发 > ecshop中商品配件功能实现和配件价格的问题

二次开发Ecshop二次开发

二次开发Ecshop二次开发

ecshop中商品配件功能实现和配件价格的问题

ecshop中,有配件这个概念。而且ecshop中配件的概念就是.在增加录入该商品A的时候,你可以录入a,b,c作为A商品的配件。

 1:增加ecshop商品配件的方法

 后台->商品管理->增加新商品->配件.在这里你可以选择某个类别下面的商品。作为配件,而且还可以指定该配件的价格。

 2:因为出现了ecshop配件的问题,所以。在购买A商品的时候,在购物车的下面,会出现该商品A下的配件。而ecshop中产品A的所有配件就存储在表group_goods中。里面存储了A的ID,也存储了配件,a,b,c的ID.用来匹配的。

 3:配件,可以在购买A的时候,计算出配件的价格。而并非配件产品本身的价格,从而可以利用配件,进行套餐的匹配.

 4:echop计算配件的价格函数分析

 function get_goods_fittings($goods_list = array())
{
$temp_index = 0;
$arr = array();

$sql = 'SELECT gg.parent_id, ggg.goods_name AS parent_name, gg.goods_id, gg.goods_price, g.goods_name, g.goods_thumb, g.goods_img, g.shop_price AS org_price, ' .
"IFNULL(mp.user_price, g.shop_price * '$_SESSION[discount]') AS shop_price ".
'FROM ' . $GLOBALS['ecs']->table('group_goods') . ' AS gg ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('goods') . 'AS g ON g.goods_id = gg.goods_id ' .
"LEFT JOIN " . $GLOBALS['ecs']->table('member_price') . " AS mp ".
"ON mp.goods_id = gg.goods_id AND mp.user_rank = '$_SESSION[user_rank]' ".
"LEFT JOIN " . $GLOBALS['ecs']->table('goods') . " AS ggg ON ggg.goods_id = gg.parent_id ".
"WHERE gg.parent_id " . db_create_in($goods_list) . " AND g.is_delete = 0 AND g.is_on_sale = 1 ".
"ORDER BY gg.parent_id, gg.goods_id";

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

while ($row = $GLOBALS['db']->fetchRow($res))
{
$arr[$temp_index]['parent_id'] = $row['parent_id'];//配件的基本件ID
$arr[$temp_index]['parent_name'] = $row['parent_name'];//配件的基本件的名称
$arr[$temp_index]['parent_short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
sub_str($row['parent_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['parent_name'];//配件的基本件显示的名称
$arr[$temp_index]['goods_id'] = $row['goods_id'];//配件的商品ID
$arr[$temp_index]['goods_name'] = $row['goods_name'];//配件的名称
$arr[$temp_index]['short_name'] = $GLOBALS['_CFG']['goods_name_length'] > 0 ?
sub_str($row['goods_name'], $GLOBALS['_CFG']['goods_name_length']) : $row['goods_name'];//配件显示的名称
$arr[$temp_index]['fittings_price'] = price_format($row['goods_price']);//配件价格
$arr[$temp_index]['shop_price'] = price_format($row['shop_price']);//配件原价格
$arr[$temp_index]['goods_thumb'] = get_image_path($row['goods_id'], $row['goods_thumb'], true);
$arr[$temp_index]['goods_img'] = get_image_path($row['goods_id'], $row['goods_img']);
$arr[$temp_index]['url'] = build_uri('goods', array('gid'=>$row['goods_id']), $row['goods_name']);
$temp_index ++;
}

return $arr;
}

本函数中告诉我们,ecshop 配件的价格,是读了group_goods表中的goods_price字段的值.而放到购物车中的时候,也是通过该字段计算。那么,配件的价格,永远能体现出.基件和配件的关系。