`
天梯梦
  • 浏览: 13627411 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论

Magento 购物车产品 Get all shopping cart items and totals

 
阅读更多

Here, I will show you how you can get information about all items in your Magento Shopping Cart. You will see how you can :-

- Get products id, name, price, quantity, etc. present in your cart.
- Get number of items in cart and total quantity in cart.
- Get base total price and grand total price of items in cart.

 

Get all items information in cart

// $items = Mage::getModel('checkout/cart')->getQuote()->getAllItems();
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
 
foreach($items as $item) {
    echo 'ID: '.$item->getProductId().'<br />';
    echo 'Name: '.$item->getName().'<br />';
    echo 'Sku: '.$item->getSku().'<br />';
    echo 'Quantity: '.$item->getQty().'<br />';
    echo 'Price: '.$item->getPrice().'<br />';
    echo "<br />";           
}

 

Get total items and total quantity in cart

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

 

Get subtotal and grand total price of cart

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

 

Hope this helps. Thanks.

 

来源:http://blog.chapagain.com.np/magento-get-all-shopping-cart-items-and-totals/

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics