ecshop为每个商品设置最少购买量(最小订购量、起订数
ecshop为每个商品设置最少购买量最小订购量/起订数1)、首先需要修改ECSHOP的数据库结构
进入 后台 》数据库管理 》SQL查询,执行下面SQL语句,注意将 “ecs_” 改成你的数据库前缀ALTER TABLE`ecs_goods` ADD`min_buynum` INT( 10 ) NOT NULL DEFAULT'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_style', '$goods_sn', '$catgory_id', " .将之修改为"VALUES ('$_POST', '$goods_name_style', '$goods_sn', '$_POST', '$catgory_id', " .继续向下,找到"goods_sn = '$goods_sn', " .在它下面增加一行代码"min_buynum = '$_POST', " .至此,后台部分修改完毕,下面开始修改前台部分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;
}
[colo
页:
[1]