ecshop添加类似于精品,新品,热销的模块

这个模块我设置它名称为“包邮”,其实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
经过本人少许修改,效果更好哦!

得意

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值