- 積分
- 1362
- 威望
- 1362
- 金錢
- 125
|
1#
發表於 2014-6-8 02:52
| 只看該作者
帖子標題: [分享] ecshop系統後臺增加商品成本價功能的設置方法
第一步:修改數據庫中的商品表ecs_goods和訂單商品表ecs_order_goods,添加成本價字段cost_price
把SQL語句列出來:
alter table `ecs_goods` add column `cost_price` decimal (10,2) UNSIGNED DEFAULT '0.00' NOT NULL after `promote_price`
alter table `ecs_order_goods` add column `cost_price` decimal (10,2) DEFAULT '0.00' NOT NULL after `market_price`
這裏是加在了字段promote_price 和market_price後面
第二步:增加語言包 ,需要修改languages\zh_cn\admin\goods.php在最後添加
$_LANG['lab_cost_price'] = '成本價:';
$_LANG['notice_cost_price'] = '該商品進貨價格(成本價,在商品添加時設置,也可以在商品編輯裏面修改 。).';
第三步:修改admin/goods.php 把成本價格插入到數據庫。
在 'promote_price' => 0,後新增一行添加
'cost_price' => 0,
再在
$shop_price = !empty($_POST['shop_price']) ? $_POST['shop_price'] : 0;後添加
$cost_price = !empty($_POST['cost_price']) ? $_POST['cost_price'] : 0;
將
if ($is_insert)
{
。。。。。源代碼太多省略(這個是真實商品和虛擬商品)
}
else
{
。。。。。源代碼太多省略
}
修改成
if ($is_insert)
{
if ($code == '')
{
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
"cat_id, brand_id, shop_price,cost_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_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
"is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, rank_integral)" .
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
"'$brand_id', '$shop_price','$cost_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_number',".
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', ".
" '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral')";
}
else
{
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
"cat_id, brand_id, shop_price,cost_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_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .
"is_on_sale, is_alone_sale, 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','$cost_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_number',".
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', ".
" '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$code', '$rank_integral')";
}
}
else
{
$sql = "SELECT goods_thumb, goods_img, original_img " .
" FROM " . $ecs->table('goods') .
" WHERE goods_id = '$_REQUEST[goods_id]'";
$row = $db->getRow($sql);
if ($proc_thumb && $goods_img && $row['goods_img'] && !goods_parse_url($row['goods_img']))
{
@unlink(ROOT_PATH . $row['goods_img']);
@unlink(ROOT_PATH . $row['original_img']);
}
if ($proc_thumb && $goods_thumb && $row['goods_thumb'] && !goods_parse_url($row['goods_thumb']))
{
@unlink(ROOT_PATH . $row['goods_thumb']);
}
$sql = "UPDATE " . $ecs->table('goods') . " SET " .
"goods_name = '$_POST[goods_name]', " .
"goods_name_style = '$goods_name_style', " .
"goods_sn = '$goods_sn', " .
"cat_id = '$catgory_id', " .
"brand_id = '$brand_id', " .
"shop_price = '$shop_price', " .
"cost_price = '$cost_price', " .
"market_price = '$market_price', " .
"is_promote = '$is_promote', " .
"promote_price = '$promote_price', " .
"promote_start_date = '$promote_start_date', " .
"promote_end_date = '$promote_end_date', ";
if ($goods_img)
{
$sql .= "goods_img = '$goods_img', original_img = '$original_img', ";
}
if ($goods_thumb)
{
$sql .= "goods_thumb = '$goods_thumb', ";
}
if ($code != '')
{
$sql .= "is_real=0, extension_code='$code', ";
}
$sql .= "keywords = '$_POST[keywords]', " .
"goods_brief = '$_POST[goods_brief]', " .
"seller_note = '$_POST[seller_note]', " .
"goods_weight = '$goods_weight'," .
"goods_number = '$goods_number', " .
"warn_number = '$warn_number', " .
"integral = '$_POST[integral]', " .
"give_integral = '$give_integral', " .
"rank_integral = '$rank_integral', " .
"is_best = '$is_best', " .
"is_new = '$is_new', " .
"is_hot = '$is_hot', " .
"is_on_sale = '$is_on_sale', " .
"is_alone_sale = '$is_alone_sale', " .
"goods_desc = '$_POST[goods_desc]', " .
"last_update = '". gmtime() ."', ".
"goods_type = '$goods_type' " .
"WHERE goods_id = '$_REQUEST[goods_id]' LIMIT 1";
}
(這步主要是在插入數據庫時,把成本價(cost_price)的值插入到數據庫)
第四步:下面應該在商品編輯頁讀取和顯示成本價格,需要修改admin/templates/goods_info.dwt
找到代碼 <tr>
<td class="label">{$lang.lab_market_price}</td>
<td><input type="text" name="market_price" value="{$goods.market_price}" size="20" />
<input type="button" value="{$lang.integral_market_price}" onclick="integral_market_price()" />
</td>
</tr>
在這段代碼之後添加顯示成本價格的表格
<!--新增 成本價 begin -->
<tr>
<td class="label">{$lang.lab_cost_price}</td>
<td><input type="text" name="cost_price" value="{$goods.cost_price}" size="20" />
<br />
<span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" {/if} id="minNumber">{$lang.notice_cost_price}</span></td>
</td>
</tr>
<!-- 成本價 end -->
這樣就完成在商品添加時增加商品的成本價和在商品列表頁編輯商品頁顯示成本價的功能。
ecshop模板
网站模板 |
提醒您:
您在" ECSHOP 交流討論區"交流請遵守台灣法律規範," 最模板"
發表的文章 《ecshop系統後臺增加商品成本價功能的設置方法》版權歸屬作者所有,如是轉貼版權歸屬原作者所有.本論壇不對其真實性做任何考證.
|