ecshop每个商品添加最少购买量最小订购量

2016-07-07 14:55 来源:www.chinab4c.com 作者:ecshop专家

第一步,商品表必须有个字段代表某个商品 最小订购数量->min_number
打开goods表在最后字段添加一个min_numbertinyint类型 默认值为0代表没有最小起订量
sql:alter table `goods` add column `min_number` tinyint (3) UNSIGNEDDEFAULT '0' NOT NULLafter `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', ";
}rnbylc63.com
jbylc29.com
lsylc269.com
hqylc218.com
zfylc46.com