...
|
...
|
@@ -425,4 +425,40 @@ class IndexController extends AbstractAction |
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 加入购物车
|
|
|
*
|
|
|
* @param string productSku 商品的SKU
|
|
|
* @param int buyNumber 购买数量
|
|
|
* @param int promotionId 促销ID, 加价购有关
|
|
|
* @param int goodsType 商品类型,0表示普通商品,1表示加价购商品
|
|
|
* @param int isEdit 是否是编辑商品SKU,0表示不是编辑
|
|
|
* @return json
|
|
|
*/
|
|
|
public function addAction()
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if ($this->isAjax()) {
|
|
|
$shoppingKey = Helpers::getShoppingKeyByCookie();
|
|
|
$productSku = $this->post('productSku');
|
|
|
$buyNumber = $this->post('buyNumber', 1);
|
|
|
$goodsType = $this->post('goodsType', 0);
|
|
|
$promotionId = $this->post('promotionId', 0);
|
|
|
$isEdit = $this->post('isEdit', 0);
|
|
|
$uid = $this->getUid(true);
|
|
|
|
|
|
// 执行加入购物车操作
|
|
|
$result = CartModel::addToCart($productSku, $buyNumber, $goodsType, $isEdit, $promotionId, $uid, $shoppingKey);
|
|
|
|
|
|
// 设置加入购物车凭证到客户端浏览器
|
|
|
if (isset($result['data']['shopping_key'])) {
|
|
|
$this->setCookie('_spk', $shoppingKey);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|