/* 将商品加入购物车 */

2016-07-07 16:49 来源:www.chinab4c.com 作者:ecshop专家

/* 将商品加入购物车 */
$cart_item = array(
'user_id' => $this->visitor->get('user_id'),
'session_id' => SESS_ID,
'store_id'=> $spec_info['store_id'],
'spec_id' => $spec_id,
'goods_id'=> $spec_info['goods_id'],
'goods_name' => addslashes($spec_info['goods_name']),
'specification' => addslashes(trim($specification)),

/* 判断用户是否是注册会员而选择写入价格*/
if $visitor.cfa_member=="0"
'price'=> $spec_info['price_all'],
else
'price'=> $spec_info['price']
'quantity'=> $quantity,
'goods_image'=> addslashes($spec_info['default_image']),
);


这样写对吗?不会PHP。语法有问题吗?

回答:
搞定了。。。
/* 将商品加入购物车 */
if ($this->visitor->get('cfa_member') != '0' and $this->visitor->get('cfa_member')> '0')
{
$price_temp= $spec_info['price'];
}
else
{
$price_temp= $spec_info['price_all'];
}

$cart_item = array(
'user_id' => $this->visitor->get('user_id'),
'session_id' => SESS_ID,
'store_id'=> $spec_info['store_id'],
'spec_id' => $spec_id,
'goods_id'=> $spec_info['goods_id'],
'goods_name' => addslashes($spec_info['goods_name']),
'specification' => addslashes(trim($specification)),
'price'=> $price_temp,
/*'price'=> $spec_info['price_all'],*/
'quantity'=> $quantity,
'goods_image'=> addslashes($spec_info['default_image']),
);