以ecshop最新版本273为例:
第一步:在goods表格增加一个字段 is_bonus 类型 tinyint 默认为1 (1是可以使用红包)
第二步:修改后台模板页 goods_info.htm
<tr id=”alone_sale_1″><td id=”alone_sale_2″>{$lang.lab_is_on_sale}</td><td id=”alone_sale_3″><input type=”checkbox” name=”is_on_sale” value=”1″ {if $goods.is_on_sale}checked=”checked”{/if} /> {$lang.on_sale_desc}</td></tr><tr id=”alone_sale_1″><td id=”alone_sale_2″>红包使用</td><td id=”alone_sale_3″><input type=”checkbox” name=”is_bonus” value=”1″ {if $goods.is_bonus}checked=”checked”{/if} /> 打勾表示允许用使用红包,否则不允许使用。</td></tr><tr><td>{$lang.lab_is_alone_sale}</td><td><input type=”checkbox” name=”is_alone_sale” value=”1″ {if $goods.is_alone_sale}checked=”checked”{/if} /> {$lang.alone_sale}</td></tr>
<tr id=”alone_sale_1″> <td id=”alone_sale_2″>{$lang.lab_is_on_sale}</td> <td id=”alone_sale_3″><input type=”checkbox” name=”is_on_sale” value=”1″ {if $goods.is_on_sale}checked=”checked”{/if} /> {$lang.on_sale_desc}</td> </tr>
<tr id=”alone_sale_1″> <td id=”alone_sale_2″>红包使用</td> <td id=”alone_sale_3″><input type=”checkbox” name=”is_bonus” value=”1″ {if $goods.is_bonus}checked=”checked”{/if} /> 打勾表示允许用使用红包,否则不允许使用。</td> </tr>
<tr> <td>{$lang.lab_is_alone_sale}</td> <td><input type=”checkbox” name=”is_alone_sale” value=”1″ {if $goods.is_alone_sale}checked=”checked”{/if} /> {$lang.alone_sale}</td> </tr>
这个大概在230行左右
*注:我没有修改语言包,如果你需要可以先去修改语言包,然后这里调言(呵呵)
第三步:修改后台goods.php文件
在添加新商品 编辑商品 下面修改
158行和230行左右的 $goods数组加下下面红色的部分(我这里默认是可以使用红包的)
$goods = array(
‘goods_id’ => 0,
‘goods_desc’ => ”,
‘cat_id’ => $last_choose[0],
‘brand_id’ => $last_choose[1],
‘is_on_sale’ => ’1′,
‘is_bonus’ => ’1′,
‘is_alone_sale’ => ’1′,
‘is_shipping’ => ’0′,
‘other_cat’ => array(), // 扩展分类
‘goods_type’ => 0, // 商品类型
‘shop_price’ => 0,
‘promote_price’ => 0,
‘market_price’ => 0,
‘integral’ => 0,
‘goods_number’ => $_CFG['default_storage'],
‘warn_number’ => 1,
‘promote_start_date’ => local_date(‘Y-m-d’),
‘promote_end_date’ => local_date(‘Y-m-d’, local_strtotime(‘+1 month’)),
‘goods_weight’ => 0,
‘give_integral’ => -1,
‘rank_integral’ => -1
);
插入和修改部份修改的代码:
805行
$is_on_sale = isset($_POST['is_on_sale']) ? 1 : 0;
$is_bonus = isset($_POST['is_bonus']) ? 1 : 0;
$is_alone_sale = isset($_POST['is_alone_sale']) ? 1 : 0;
/* 入库 */
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_number, warn_number, integral, give_integral, is_best, is_new, is_hot, ” .
“is_on_sale, is_bonus,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_number’,”.
” ‘$warn_number’, ‘$_POST[integral]‘, ‘$give_integral’, ‘$is_best’, ‘$is_new’, ‘$is_hot’, ‘$is_on_sale’,‘$is_bonus’,’$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_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, ” .
“is_on_sale,is_bonus,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_number’,”.
” ‘$warn_number’, ‘$_POST[integral]‘, ‘$give_integral’, ‘$is_best’, ‘$is_new’, ‘$is_hot’, 0, ‘$is_on_sale’,‘$is_bonus’,$is_alone_sale’, $is_shipping, “.
” ‘$_POST[goods_desc]‘, ‘” . gmtime() . “‘, ‘”. gmtime() .”‘, ‘$goods_type’, ‘$code’, ‘$rank_integral’)”;
}
}
901行:
$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_bonus = ‘$is_bonus’, ” .
“is_on_sale = ‘$is_on_sale’, ” .
“is_alone_sale = ‘$is_alone_sale’, ” .
“is_shipping = ‘$is_shipping’, ” .
“goods_desc = ‘$_POST[goods_desc]‘, ” .
“last_update = ‘”. gmtime() .”‘, “.
“goods_type = ‘$goods_type’ ” .
“WHERE goods_id = ‘$_REQUEST[goods_id]‘ LIMIT 1″;
第四步:修改后台模板页goods_list.htm
25行:
<th><a href=”javascript:listTable.sort(‘is_hot’); “>{$lang.is_hot}</a>{$sort_is_hot}</th>
<th><a href=”javascript:listTable.sort(‘is_bonus’); “>红包</a>{$sort_is_bonus}</th>
<th><a href=”javascript:listTable.sort(‘sort_order’); “>{$lang.sort_order}</a>{$sort_sort_order}</th>
47行:
<td align=”center”><img src=”images/{if $goods.is_hot}yes{else}no{/if}.gif” onclick=”listTable.toggle(this, ‘toggle_hot’, {$goods.goods_id})” /></td>
<td align=”center”><img src=”images/{if $goods.is_bonus}yes{else}no{/if}.gif” onclick=”listTable.toggle(this, ‘toggle_bonus’, {$goods.goods_id})” /></td>
<td align=”center”><span onclick=”listTable.edit(this, ‘edit_sort_order’, {$goods.goods_id})”>{$goods.sort_order}</span></td>
98行:
<option value=”not_hot”>{$lang.not_hot}</option>
<option value=”bonus”>使用红包</option>
<option value=”not_bonus”>取消红包使用</option>
<option value=”move_to”>{$lang.move_to}</option>
第五步:修改后台goods.php
在1500行左右加上
/*—————————————————— */
//– 修改红包使用状态
/*—————————————————— */
elseif ($_REQUEST['act'] == ‘toggle_bonus’)
{
check_authz_json(‘goods_manage’);
$goods_id = intval($_POST['id']);
$is_bonus = intval($_POST['val']);
if ($exc->edit(“is_bonus = ‘$is_bonus’, last_update=” .gmtime(), $goods_id))
{
clear_cache_files();
make_json_result($is_bonus);
}
}
/*—————————————————— */
//– 修改商品排序
/*—————————————————— */
新闻热点
疑难解答