ecshop最低起订量应该如何设置?

 我来答
ecshop开发中心
2013-08-20 · TA获得超过577个赞
知道大有可为答主
回答量:2299
采纳率:0%
帮助的人:579万
展开全部
为每个商品设置最少购买量最小订购量

1)、
首先需要修改ECSHOP的数据库结构
进入 后台 》数据库管理 》SQL查询,执行下面SQL语句,注意将 “ecs_” 改成你的数据库前缀
ALTER TABLE `ecs_goods` ADD `min_buynum` INT( 1NULL '0';
2)、
修改 /admin/templates/goods_info.htm

{if $suppliers_exists eq 1}

上边增加代码

<tr>
<td class="label">最小起订数</td>
<td><input type="text" name="min_buynum" value="{$goods.min_buynum}"/></td>
</tr>

3)、
修改 /admin/goods.php
找到(注意:一共能找到两处,都要修改才行)
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
将之修改为
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, min_buynum, " .

继续,找到(注意:一共能找到两处,都要修改才行)
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
将之修改为
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$_POST[min_buynum]', '$catgory_id', " .
继续向下,找到
"goods_sn = '$goods_sn', " .
在它下面增加一行代码
"min_buynum = '$_POST[min_buynum]', " .
至此,后台部分修改完毕,下面开始修改前台部分
4)、
这里以官方默认模板为例进行讲解,其他模板请自行对照修改
打开文件 /themes/default/goods.dwt

<input name="number" type="text" id="number" value="1" size="4" style="border:1px solid #ccc; "/>
修改为
<input name="number" type="text" id="number" value="{$goods.min_buynum|default:"1"}" size="4" style="border:1px solid #ccc; "/>
继续向下,找到
var qty = document.forms['ECS_FORMBUY'].elements['number'].value;
在它下边增加一段代码
<!--{if $goods.min_buynum}-->
if(qty<{$goods.min_buynum})
{
alert('对不起,本商品最小起订数为:{$goods.min_buynum}');
qty={$goods.min_buynum}
}
<!--{/if}-->
5)、
打开文件 /flow.php
找到
$sql = "SELECT g.goods_name, g.goods_number ".
修改为
$sql = "SELECT g.goods_name, g.goods_number, g.min_buynum ".
找到
//查询:系统启用了库存,检查输入的商品数量是否有效

在它上边增加
/* 比较购买数量与最小起定数*/
if($row['min_buynum']>$val)
{
show_message(sprintf('对不起,您选择的商品%s,最小起订数%d件。',
$row['goods_name'],$row[' min_buynum']),'返回购物车','?step=cart');
exit;
}

转载请注明:68ECshop模板(全国最专业的ECSHOP模板制作商)
追问
这么麻烦啊!在common。js中,添加商品到购物车方法中设置最低起订量,不行么?
追答
修改之前记得备份数据,先试试吧。
AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
ecmoban模板堂
2013-08-20 · TA获得超过770个赞
知道大有可为答主
回答量:2259
采纳率:66%
帮助的人:903万
展开全部
第一步,商品表必须有个字段 代表某个商品 最小订购数量->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}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式