这个模块我设置它名称为“包邮”,其实ecshop已经有包邮功能,不用另外做开发,这里只是新建一个模块做示范,请不必纠结。
1.在数据库中ecs_goods添加字段is_baoyou,执行语句
ALTER TABLE `ecs_goods` ADD `is_baoyou` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `is_hot` ;
2.admin/goods.php,在
$is_hot = isset($_POST['is_hot']) ? 1 : 0;
后,添加
$is_baoyou = isset($_POST['is_baoyou']) ? 1 : 0;
将
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
修改为
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_baoyou, " .
将
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', $is_shipping, ".
修改为
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_baoyou', '$is_on_sale', '$is_alone_sale', $is_shipping, ".
将
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_real, " .
修改为
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, is_baoyou, is_real, " .
将
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', 0, '$is_on_sale', '$is_alone_sale', $is_shipping, ".
修改为
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_baoyou', 0, '$is_on_sale', '$is_alone_sale', $is_shipping, ".
在
"is_hot = '$is_hot', " .
后,添加
"is_baoyou = '$is_baoyou', " .
在
/* 设为新品 */
elseif ($_POST['type'] == 'new')
{
/* 检查权限 */
admin_priv('goods_manage');
update_goods($goods_id, 'is_new', '1');
}
/* 取消新品 */
elseif ($_POST['type'] == 'not_new')
{
/* 检查权限 */
admin_priv('goods_manage');
update_goods($goods_id, 'is_new', '0');
}
后,添加
/* 设为包邮 */
elseif ($_POST['type'] == 'is_baoyou')
{
/* 检查权限 */
admin_priv('goods_manage');
update_goods($goods_id, 'is_baoyou', '1');
}
/* 取消包邮 */
elseif ($_POST['type'] == 'not_baoyou')
{
/* 检查权限 */
admin_priv('goods_manage');
update_goods($goods_id, 'is_baoyou', '0');
}
在
/*------------------------------------------------------ */
//-- 修改热销推荐状态
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'toggle_hot')
{
check_authz_json('goods_manage');
$goods_id = intval($_POST['id']);
$is_hot = intval($_POST['val']);
if ($exc->edit("is_hot = '$is_hot', last_update=" .gmtime(), $goods_id))
{
clear_cache_files();
make_json_result($is_hot);
}
}
后,添加
/*------------------------------------------------------ */
//-- 修改包邮推荐状态
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'toggle_baoyou')
{
check_authz_json('goods_manage');
$goods_id = intval($_POST['id']);
$is_baoyou = intval($_POST['val']);
if ($exc->edit("is_baoyou = '$is_baoyou', last_update=" .gmtime(), $goods_id))
{
clear_cache_files();
make_json_result($is_baoyou);
}
}
3.admin/includes/lib_goods.php,搜索function goods_list($is_delete, $real_goods=1, $conditions = '')在
case 'is_new':
$where .= ' AND is_new=1';
break;
后,添加
case 'is_baoyou':
$where .= ' AND is_baoyou=1';
break;
将
$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, " .
改为
$sql = "SELECT goods_id, goods_name, goods_type, goods_sn, shop_price, is_on_sale, is_best, is_new, is_hot, is_baoyou, sort_order, goods_number, integral, " .
4.admin/templates/goods_info.htm,在
<input type="checkbox" name="is_hot" value="1" {if $goods.is_hot}checked="checked"{/if} />{$lang.is_hot}
后,添加
<input type="checkbox" name="is_baoyou" value="1" {if $goods.is_baoyou}checked="checked"{/if} />{$lang.is_baoyou}
在
<br /><label for="auto_thumb"><input type="checkbox" id="auto_thumb" name="auto_thumb" checked="true" value="1" οnclick="handleAutoThumb(this.checked)" />{$lang.auto_thumb}</label>{/if}
</td>
</tr>
后,添加
<tr>
<td class="label">{$lang.is_baoyou}</td>
<td><input type="text" name="is_baoyou" value="{$goods.is_baoyou}" size="20"/>
</td>
</tr>
5.admin/templates/goods_list.htm,在
<th><a href="javascript:listTable.sort('is_hot'); ">{$lang.is_hot}</a>{$sort_is_hot}</th>
后,添加
<th><a href="javascript:listTable.sort('is_baoyou'); ">{$lang.is_baoyou}</a>{$sort_is_baoyou}</th>
在
<td align="center"><img src="images/{if $goods.is_hot}yes{else}no{/if}.gif" οnclick="listTable.toggle(this, 'toggle_hot', {$goods.goods_id})" /></td>
后,添加
<td align="center"><img src="images/{if $goods.is_baoyou}yes{else}no{/if}.gif" οnclick="listTable.toggle(this, 'toggle_baoyou', {$goods.goods_id})" /></td>
在
<option value="hot">{$lang.hot}</option>
<option value="not_hot">{$lang.not_hot}</option>
后,添加
<option value="baoyou">{$lang.baoyou}</option>
<option value="not_baoyou">{$lang.baoyou}</option>
6.languages\zh_cn\admin\goods.php
在
$_LANG['batch_hot_confirm'] = '您确实要把选中的商品设为热销吗?';
$_LANG['batch_not_hot_confirm'] = '您确实要把选中的商品取消热销吗?';
后,添加
$_LANG['batch_baoyou_confirm'] = '您确实要把选中的商品设为包邮吗?';
$_LANG['batch_not_baoyou_confirm'] = '您确实要把选中的商品取消包邮吗?';
在
$_LANG['is_hot'] = '热销';
后,添加
$_LANG['is_baoyou'] = '包邮';
在
$_LANG['hot'] = '热销';
$_LANG['not_hot'] = '取消热销';
后,添加
$_LANG['baoyou'] = '包邮';
$_LANG['not_baoyou'] = '取消包邮';
效果如图所示:
转载自http://bbs.ecshop.com/thread-1118559-1-1.html
经过本人少许修改,效果更好哦!