ecshop商品新增字段的方法很多,但是都是仅仅显示出来而已。没有实现随购物车添加进订单。今天多变PHP服务中心技术为大家提供一份更详尽的技术资料(本例是以给商品增加分成金额)。
数据库部分
ALTER TABLE ecs_goods ADD fc_fee decimal(10,2) unsigned zerofill NOT NULL;
ALTER TABLE ecs_cart ADD fc_fee decimal(10,2) unsigned zerofill NOT NULL;
ALTER TABLE ecs_order_info ADD fc_fee decimal(10,2) unsigned zerofill NOT NULL;
后台部分
admin/goods.php
查找(共两处)
'promote_end_date' => local_date('Y-m-d', gmstr2tome('+1 month')),
'goods_weight' => 0,
给其下面添加
'fencheng' => 0.00,
查找
$goods_type = isset($_POST['goods_type']) ? $_POST['goods_type'] : 0;
$give_integral = isset($_POST['give_integral']) ? intval($_POST['give_integral']) : '-1';
给其下面增加
$fc_fee = isset($_POST['fc_fee']) ? $_POST['fc_fee'] : '0.00';
继续查找
/* 入库 */
if ($is_insert)
{
给其下面两段SQL里面分别加入fc_fee, $fc_fee
继续查找
"give_integral = '$give_integral', " .
"rank_integral = '$rank_integral', " .
给其下面增加
"fc_fee= '$fc_fee', " .
admin/includes/lib_goods.php
查找
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, sort_order, goods_number, integral, sales_volume_base, " .
给这段sql内增加fc_fee
admin/templates/goods_info.htm
查找
{$lang.lab_market_price}
给其上面增加
分成金额
admin/templates/goods_list.htm
查找
{$lang.is_hot}{$sort_is_hot}
给其下面增加
分成金额
继续查找
给其下面增加
{$goods.fc_fee}
前台部分
goods.php
查找
$shop_price = $goods['shop_price'];
给其下面增加
$fc_fee = price_format($goods['fc_fee']);
goods.dwt
在其合适位置添加该买本商品可介绍者可返利基数为{$goods.fc_fee}
includes/lib_goods.php
查找
function addto_cart($goods_id, $num = 1, $spec = array(), $parent = 0)
给该函数内的sql加入
g.fc_fee
继续查找
$parent['goods_number'] = $num;
给其下方添加
$parent['fc_fee'] = $goods['fc_fee'];
继续查找
function cart_goods($type = CART_GENERAL_GOODS)
给该函数内的sql加入fc_fee
继续查找 (这段是计算分成费用,可以根据情况自行修改方法)
function order_fee($order, $goods, $consignee)
查找
$total['goods_price'] += $val['goods_price'] * $val['goods_number'];
给其下面增加
if(!empty($val['fc_fee'])){
$total['fc_fee'] += $val['fc_fee'] * $val['goods_number'];
}else{
$total['fc_fee'] += $val['goods_price'] * $val['goods_number'];
}
flow.php
查找$order['bonus'] = $total['bonus'];
$order['goods_amount'] = $total['goods_price'];
给其下面增加
$order['fc_fee'] = $total['fc_fee'];
至此,该字段彻底添加完成,至于返利的各种操作,大家可以尽情发挥!
本文地址:https://www.phpicu.com/article.php?id=46