ecshop在添加新商品时加入任意字段并模板中调用
1.ecshop数据库新增一个字段
可以用mysql语句,也可以用phpmyadmin或其它数据库管理工具增加ecshop字段
2.修改admin/good.php
查找 $shop_price = !empty($_POST[‘shop_price’]) ? $_POST[‘shop_price’] : 0;
在下面添加
$goods_profit = !empty($_POST[‘goods_profit’]) ? $_POST[‘goods_profit’] : 0;
查找 if ($is_insert)
在4处地方加入SQL的插入。
我插入后的语句
if ($is_insert)
{
if ($code == ”)
{
$sql = “INSERT INTO ” . $ecs->table(‘goods’) . ” (goods_name, goods_name_style, goods_sn, ” .
“cat_id, brand_id, shop_price, market_price, is_promote, promote_price, ” .
“promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, ” .
“seller_note, goods_weight, goods_profit, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, ” .
“is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, rank_integral, suppliers_id)” .
“VALUES (‘$_POST[goods_name]’, ‘$goods_name_style’, ‘$goods_sn’, ‘$catgory_id’, ” .
“‘$brand_id’, ‘$shop_price’, ‘$market_price’, ‘$is_promote’,’$promote_price’, “.
“‘$promote_start_date’, ‘$promote_end_date’, ‘$goods_img’, ‘$goods_thumb’, ‘$original_img’, “.
“‘$_POST[keywords]’, ‘$_POST[goods_brief]’, ‘$_POST[seller_note]’, ‘$goods_weight’, ‘$goods_profit’, ‘$goods_number’,”.
” ‘$warn_number’, ‘$_POST[integral]’, ‘$give_integral’, ‘$is_best’, ‘$is_new’, ‘$is_hot’, ‘$is_on_sale’, ‘$is_alone_sale’, $is_shipping, “.
” ‘$_POST[goods_desc]’, ‘” . gmtime() . “‘, ‘”. gmtime() .”‘, ‘$goods_type’, ‘$rank_integral’, ‘$suppliers_id’)”;
}
else
{
$sql = “INSERT INTO ” . $ecs->table(‘goods’) . ” (goods_name, goods_name_style, goods_sn, ” .
“cat_id, brand_id, shop_price, market_price, is_promote, promote_price, ” .
“promote_start_date, promote_end_date, goods_img, goods_thumb, original_img, keywords, goods_brief, ” .
“seller_note, goods_weight, goods_profit, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, ” .
“is_on_sale, is_alone_sale, is_shipping, goods_desc, add_time, last_update, goods_type, extension_code, rank_integral)” .
“VALUES (‘$_POST[goods_name]’, ‘$goods_name_style’, ‘$goods_sn’, ‘$catgory_id’, ” .
“‘$brand_id’, ‘$shop_price’, ‘$market_price’, ‘$is_promote’,’$promote_price’, “.
“‘$promote_start_date’, ‘$promote_end_date’, ‘$goods_img’, ‘$goods_thumb’, ‘$original_img’, “.
“‘$_POST[keywords]’, ‘$_POST[goods_brief]’, ‘$_POST[seller_note]’, ‘$goods_weight’, ‘$goods_profit’, ‘$goods_number’,”.
” ‘$warn_number’, ‘$_POST[integral]’, ‘$give_integral’, ‘$is_best’, ‘$is_new’, ‘$is_hot’, 0, ‘$is_on_sale’, ‘$is_alone_sale’, $is_shipping, “.
” ‘$_POST[goods_desc]’, ‘” . gmtime() . “‘, ‘”. gmtime() .”‘, ‘$goods_type’, ‘$code’, ‘$rank_integral’)”;
}
}
基本上就是在对应的goods_weight后面加入goods_profit 总共有4处
查找 “goods_weight = ‘$goods_weight’,” .
在下面加入
“goods_profit = ‘$goods_profit’,”.
在后台添加新商品的地方加入商品利润
找到 admintemplatesgoods_info.htm
在你想加入的地方添加
<tr>
<td class=”label”>商品利润:</td>
<td><input type=”text” name=”goods_profit” value=”{$goods.goods_profit}” size=”20″ />
</td>
</tr>
在模板中用{$goods.goods_profit} 来调用,我们一般再good.dwt里面调用
后台商品列表页显示这个字段请看我下一篇文章,并可以ajax修改