关于商品详情页货品(属性库存)的显示问题

2016-07-07 15:26 来源:www.chinab4c.com 作者:ecshop专家

/*------------------------------------------------------ */
//-- 改变属性、数量时重新计算商品价格
/*------------------------------------------------------ */
if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'price')
{
include('includes/cls_json.php');
$json= new JSON;
$res = array('err_msg' => '', 'result' => '', 'qty' => 1);
$attr_id = isset($_REQUEST['attr']) ? explode(',', $_REQUEST['attr']) : array();
$number= (isset($_REQUEST['number'])) ? intval($_REQUEST['number']) : 1;
if ($goods_id == 0)
{
$res['err_msg'] = $_LANG['err_change_attr'];
$res['err_no']= 1;
}
else
{
if ($number == 0)
{
$res['qty'] = $number = 1;
}
else
{
$res['qty'] = $number;
}
$shop_price= get_final_price($goods_id, $number, true, $attr_id);
$res['result'] = price_format($shop_price * $number);
}
die($json->encode($res));
}

<新增的代码开始>
if (!empty($_REQUEST['act']) && $_REQUEST['act'] == 'change')
{
include('includes/cls_json.php');

$json= new JSON;
$res = array('err_msg' => '', 'result' => '','div_id'=>'');

$goods_id = intval(trim($_REQUEST['id']));
$product_id= intval(trim($_REQUEST['attr_id']));

$attr_count = $db -> getOne("select product_number from ".$ecs->table('products')." where goods_id = '$goods_id' and goods_attr = '$product_id'");
if($attr_count > 0){
$res['result'] = ' 可发货';
}else{
$res['result'] = ' 暂缺货';
}
$res['div_id'] = trim($_REQUEST['div_id']);
die($json->encode($res));
}

<新增的代码结束>

偶在2.7.2版本里的goods.php里加了以上代码,在商品详情页选择某属性的时候就提示是否可发货,但却没任何提示,那位大侠指点下以上程序为什么不起作用的呢??

回答:
程序修改可以到开发交流区看下

发错地方了 lz