一聚教程网:一个值得你收藏的教程网站

热门教程

magento 购物车仿京东勾选下单实现教程

时间:2022-11-14 22:03:53 编辑:袖梨 来源:一聚教程网

gouxuan

jd-gouxuan


该功能仿照了Wishlist功能,构造了一个新的购物车系统,用户更新删除购物车item ,操作新的数据库表

两个方法

public function removeCancelByAjaxAction()
{
$result = array();
$itemId = (int) $this->getRequest()->getParam('itemId');
if($itemId){
try{
$newQuoteItemId = Mage::getModel("newshoppingcart/simulation")->addNCItemToCart($itemId);
$result['status'] = "success";
$result['content'] = $this->getLayout()->createBlock('checkout/cart_totals')->setTemplate('checkout/cart/totals.phtml')->toHtml();
$result['newQuoteId'] = $newQuoteItemId;
}catch (Exception $e){
$result['status'] = "fail";
$result['error'] = "Exception when call addNItemToCart function,Msg:".$e->getMessage();
}
}
echo json_encode($result);
}

public function removeCancelByAjaxAction()
{
$result = array();
$itemId = (int) $this->getRequest()->getParam('itemId');
if($itemId){
try{
$newQuoteItemId = Mage::getModel("newshoppingcart/simulation")->addNCItemToCart($itemId);
$result['status'] = "success";
$result['content'] = $this->getLayout()->createBlock('checkout/cart_totals')->setTemplate('checkout/cart/totals.phtml')->toHtml();
$result['newQuoteId'] = $newQuoteItemId;
}catch (Exception $e){
$result['status'] = "fail";
$result['error'] = "Exception when call addNItemToCart function,Msg:".$e->getMessage();
}
}
echo json_encode($result);
}

热门栏目