您现在的位置是:首页 > 教程 > ecshop商城教程ecshop商城教程
ecshop商品购买批发起订量数量插件开发教程
香巧2023-11-30 21:18:50ecshop商城教程已有人查阅
导读做过ECSHOP商城,或者说经营过商城的都会知道,有很多商品利润很小,而且还要包运费什么的,所以根本就是做 的生意,如果利润小
做过ECSHOP商城,或者说经营过商城的都会知道,有很多商品利润很小,而且还要包运费什么的,所以根本就是做 的生意,如果利润小,数量多的话这样就不会出现赔本的损失。所以 今天 个插件也是很实用的插件就是如果在后台设置商品很小起订量
步骤一,商品表必须有个字段 代表某个商品 很小订购数量->min_number
打开goods表在最后字段添加一个min_number tinyint类型 默认值为0 代表没有很小起订量
admin/goods.php
在'warn_number'=> 1 , 代码行后插入'min_number'=> 0,
在$warn_number = isset($_POST['warn_number']) ? $_POST['warn_number'] : 0;
后添加代码$min_number = isset($_POST['min_number']) ? $_POST['min_number'] : 0;
步骤三,修改添加商品sql语句
修改代码
admin/templates/goods_info.htm
在
最后添加
下面我门说说前台如何来实现
我以default模板为例子给大家讲解
想做起订量限制,这个必然是在商品购买页面 购买数量框来做限制 最简单的办法就是用JS当然还有别的办法
首先给那些如果给了起订量的商品 购买页面直接显示默认最少购买数量
如果在后台设置的AA商品最少5个那么进入AA商品页面购买数量默认值就是5
我这样来实现
修改themes/default/goods.dwt
最后添加JS判断就好了
themes/default/goods.dwt
在
步骤一,商品表必须有个字段 代表某个商品 很小订购数量->min_number
打开goods表在最后字段添加一个min_number tinyint类型 默认值为0 代表没有很小起订量
sql:alter table `goods` add column `min_number` tinyint (3) UNSIGNED DEFAULT '0' NOT NULL after `warn_number`
步骤二,在后台添加商品的时候 必须有个text文本框 设置很小起订量admin/goods.php
在'warn_number'=> 1 , 代码行后插入'min_number'=> 0,
在$warn_number = isset($_POST['warn_number']) ? $_POST['warn_number'] : 0;
后添加代码$min_number = isset($_POST['min_number']) ? $_POST['min_number'] : 0;
步骤三,修改添加商品sql语句
修改代码
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,min_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', '$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','$min_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, 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, min_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', '$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','$min_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', " .
"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', " .
"min_number = '$min_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";
}
步骤四,修改后台模板文件(在市场价会员价 后边添加设置很小起订量)admin/templates/goods_info.htm
在
<tr>
<td class="label">{$lang.lab_shop_price}</td>
<td><input type="text" name="market_price" value="{$goods.shop_price}" size="20" />
<input type="button" value="{$lang.integral_market_price}" onclick="integral_market_price()" />{$lang.require_field}</td>
</tr>
添加
<!-- 新增 批发数量限制 begin -->
<tr>
<td class="label">{$lang.lab_min_number}</td>
<td><input type="text" name="min_number" value="{$goods.min_number}" size="20" />
<span class="notice-span" {if $help_open}style="display:block" {else} style="display:none" mce_style="display: none;" {/if} id="minNumber">{$lang.notice_min_number}</span>
</td>
</td>
</tr>
<!-- 批发数量限制 end -->
步骤五,修改语言languages/zh_cn/admin/goods.php最后添加
$_LANG['lab_min_number']= '很小购买数量:';
$_LANG['notice_min_number']= '该商品很小购买数量,0表示按购买数量制.'
到现在位置 后台设置全部结束了,不知道大家能懂了没有下面我门说说前台如何来实现
我以default模板为例子给大家讲解
想做起订量限制,这个必然是在商品购买页面 购买数量框来做限制 最简单的办法就是用JS当然还有别的办法
首先给那些如果给了起订量的商品 购买页面直接显示默认最少购买数量
如果在后台设置的AA商品最少5个那么进入AA商品页面购买数量默认值就是5
我这样来实现
修改themes/default/goods.dwt
<input name="number" type="text" id="number" value="1" size="4" onBlur="changePrice()" style="border:1px solid #ccc; " mce_style="border: 1px solid #ccc;"/>
改成
<input name="number" type="text" id="number" value="{$goods.min_number|default:"1"}" size="4" onblur="changePrice()" style=”border:1px solid #ccc; " mce_style="border: 1px solid #ccc;"/><br />
这样就是value 也就是默认值了 最后添加JS判断就好了
themes/default/goods.dwt
在
var qty = document.forms['ECS_FORMBUY'].elements['number'].value;
后添加
{if $goods.min_number}
if(qty < {$goods.min_number})
{
alert('您输入的数字小于此商品很小购买数量:{$goods.min_number}');
qty = {$goods.min_number};
}
{/if}
本文标签:
很赞哦! ()
随机图文
-
ecshop后台会员列表页增加按手机查询会员的实现方法
1、首先修改程序文件 admin/users.php;2、修改模板文件 admin/templates/users_list.htm -
ecshop首页商品怎么实现随机排序
首页ecshop商品随机排序的三种方法都是修改inlcudes/lib_goods.php这个文件1 精品推荐 新品上架 热卖商品 促销商品 团购商品 拍卖商品 6类随机排序的调整方法 -
ecshop关联商品超过50个的修改方法
在ecshop中 的商品详情里,增加关联商品时,最多只能关联50个,那么应该如何解除这个限制呢,其实很简单打开 admin/includes/lib_main.php找到 -
在ecshop商品游客发表评论取消E-MAIL必填的方法
ECSHOP的商品详情页,在用户提交评论的时候,那个“E-MAIL”输入框默认是“必填”的。如果我想改成“E-MAIL非必填”或者干脆“删除这个E-MAIL输入框”
留言与评论 (共有 条评论) |