首页 > 代码库 > Magento获取购物车所有信息

Magento获取购物车所有信息

Magento获取购物车数量和价格以及购物车所有信息,
$items = Mage::getSingleton(‘checkout/session‘)->getQuote()->getAllItems();  //获取所有的信息集合

foreach($items as $item) {
echo ‘ID: ‘.$item->getProductId().‘‘;
echo ‘Name: ‘.$item->getName().‘‘;
echo ‘Sku: ‘.$item->getSku().‘‘;
echo ‘Quantity: ‘.$item->getQty().‘‘;
echo ‘Price: ‘.$item->getPrice().‘‘;
echo "";
}

//获取产品的数量

$totalItems = Mage::getModel(‘checkout/cart‘)->getQuote()->getItemsCount();
$totalQuantity = Mage::getModel(‘checkout/cart‘)->getQuote()->getItemsQty();

//获取产品的价格

$subTotal = Mage::getModel(‘checkout/cart‘)->getQuote()->getSubtotal();
$grandTotal = Mage::getModel(‘checkout/cart‘)->getQuote()->getGrandTotal();

Magento获取购物车所有信息