ecshop二次开发属性库存缺货的思路
2010-02-04 22:48 来源:www.chinab4c.com 作者:admin
在ecshop二次开发的过程中,我们往往会遇到给属性增加库存,我们已经实现了给ecshop属性增加库存管理,如果我们要处理属性缺货,那么我们还需要做另外一个尝试.ecshop二次开发属性缺货
1:ecshop的flow.php中增加
//===================================
//属性库存和购买关联起来
//===================================
if(!empty($goods->spec)){//如果选择了属性
$sql = "SELECT a.attr_id, a.attr_name, a.attr_type, ".
"g.goods_attr_id, g.attr_value, g.attr_price ,g.attr_count " .
'FROM ' . $GLOBALS['ecs']->table('goods_attr') . ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('attribute') . ' AS a ON a.attr_id = g.attr_id ' .
"WHERE a.attr_type != 0 AND g.goods_id = '" . $goods->goods_id . "' and g.attr_id " .
'ORDER BY a.sort_order, g.attr_price, g.goods_attr_id';
$res = $GLOBALS['db']->getAll($sql);
if($res){
foreach ($res AS $row)
{ if(in_array($row['goods_attr_id'],$goods->spec)){//如果取得属性ID在列表属性内,要判断属性库存
if($goods->number > $row['attr_count']){//如果库存大于该颜色尺寸,进行缺货登记
$result['error'] = 2;
$result['goods_id'] = $goods->goods_id;
$result['parent'] = $goods->parent;
$result['message'] = $row['attr_name']."为".$row['attr_value']."的库存不足,只有". $row['attr_count']."件,请进行缺货登记!";
die($json->encode($result));
}
}
}
}
}
//===================================
//属性库存和购买关联起来
//===================================
2:ecshop的flow.php中的update
if($goods['goods_attr_id']){//如果选择了属性
$ar = explode(",",$goods['goods_attr_id']);
$sql = "SELECT a.attr_id, a.attr_name, a.attr_type, ".
"g.goods_attr_id, g.attr_value, g.attr_price ,g.attr_count " .
'FROM ' . $GLOBALS['ecs']->table('goods_attr') . ' AS g ' .
'LEFT JOIN ' . $GLOBALS['ecs']->table('attribute') . ' AS a ON a.attr_id = g.attr_id ' .
"WHERE a.attr_type != 0 AND g.goods_id = '" . $goods['goods_id'] . "' and g.attr_id " .
'ORDER BY a.sort_order, g.attr_price, g.goods_attr_id';
$res = $GLOBALS['db']->getAll($sql);
if($res){
foreach ($res AS $row)
{ if(in_array($row['goods_attr_id'],$ar)){//如果取得属性ID在列表属性内,要判断属性库存
if($val > $row['attr_count']){//如果库存大于该颜色尺寸,进行缺货登记
show_message($row['attr_name']."为".$row['attr_value']."的库存不足,只有". $row['attr_count']."件,请进行缺货登记!");
exit;
}
}
}
}
}
来源:中国B4C电子商务
最近更新
常用插件
- ecshop红包修改成满多少减
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...
- ecshop分类树中统计商品数
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...
- ecshop通用红包编码
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...
- ecshop购物车功能改进[插件
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...