网站地图    收藏   

主页 > 前端 > css教程 >

ecshop红包指定某些商品不能使用修改步骤 - html

来源:自学PHP网    时间:2015-04-14 14:50 作者: 阅读:

[导读] 第一步:在goods表格增加一个字段 is_bonus 类型 tinyint 默认为1 (1是可以使用红包)第二步:修改后台模板页 goods_info.htmtr id=alone_sale_1Prime;td id=alone_sale_2Prime;{$lang.lab_is_on_s......

第一步:在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);

}

}

/*—————————————————— */

//– 修改商品排序

/*—————————————————— */

到此后台功能已经修改完成

再修改前台:

首页在tb_cart表中加一个字段 is_bonus 类型 tinyint 默认为1 (1是可以使用红包)

找到includes/lib_order.php 中的 function  addto_cart

1022行:

$sql = “SELECT g.goods_name, g.goods_sn, g.is_on_sale, g.is_real,g.is_bonus, “.

“g.market_price, g.shop_price AS org_price, g.promote_price, g.promote_start_date, “.

“g.promote_end_date, g.goods_weight, g.integral, g.extension_code, “.

“g.goods_number, g.is_alone_sale, g.is_shipping,”.

“IFNULL(mp.user_price, g.shop_price * ‘$_SESSION[discount]‘) AS shop_price “.

” FROM ” .$GLOBALS['ecs']->table(‘goods’). ” AS g “.

” LEFT JOIN ” . $GLOBALS['ecs']->table(‘member_price’) . ” AS mp “.

“ON mp.goods_id = g.goods_id AND mp.user_rank = ‘$_SESSION[user_rank]‘ “.

” WHERE g.goods_id = ‘$goods_id’” .

” AND g.is_delete = 0″;

1117行:

/* 初始化要插入购物车的基本件数据 */www.2cto.com

$parent = array(

‘user_id’       => $_SESSION['user_id'],

‘session_id’    => SESS_ID,

‘goods_id’      => $goods_id,

‘goods_sn’      => addslashes($goods['goods_sn']),

‘product_id’    => $product_info['product_id'],

‘goods_name’    => addslashes($goods['goods_name']),

‘market_price’  => $goods['market_price'],

‘goods_attr’    => addslashes($goods_attr),

‘goods_attr_id’ => $goods_attr_id,

‘is_real’       => $goods['is_real'],

‘extension_code’=> $goods['extension_code'],

‘is_gift’       => 0,

‘is_bonus’      => $goods['is_bonus'],

‘is_shipping’   => $goods['is_shipping'],

‘rec_type’      => CART_GENERAL_GOODS

);

再修改:function order_fee 大概在545行

/* 商品总价 */

foreach ($goods AS $val)

{

/* 统计实体商品的个数 */

if ($val['is_real'])

{

$total['real_goods_count']++;

}

if($val['is_bonus'])

{

$total['goods_bonus_price']  += $val['goods_price'] * $val['goods_number'];

}

$total['goods_price']  += $val['goods_price'] * $val['goods_number'];

$total['market_price'] += $val['market_price'] * $val['goods_number'];

}

最后一步就是修改flow.php

大概在686行

/* 如果使用红包,取得用户可以使用的红包及用户选择的红包 */

if ((!isset($_CFG['use_bonus']) || $_CFG['use_bonus'] == ’1′)

&& ($flow_type != CART_GROUP_BUY_GOODS && $flow_type != CART_EXCHANGE_GOODS))

{

// 取得用户可用红包

$user_bonus = user_bonus($_SESSION['user_id'], $total['goods_bonus_price']);

此功能有个缺陷就是指定商品不能用红包,所有的红包都不能用了

 

摘自 顺子网络 PHP网站建设

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论