首先在订单中的商品信息【编辑】页面中,修改成本价。也可以在添加商品时添加成本的如果不做手工修改,则使用默认的商品成本价(在商品信息里编辑的成本
价格)。
第一步:修改数据库中的商品表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 把成本价格插入到数据库 在两个(有两个地方需要修改)
后新增一行添加再在
- $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 -->
复制代码这样就把就完成了在商品添加时增加商品的成本价和在商品列表页编辑商品页显示成本价的功能
1.修改订单的语言文件languages\zh_cn\a |