如何使用模型在购物车中获取商品? (Magento) [英] How do i get items in shopping cart using models? (Magento)
本文介绍了如何使用模型在购物车中获取商品? (Magento)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有任何代码可以使用任何模型或助手从magento提取添加到购物车中的物品及其数量?
Is there any code with which i could fetch items added to the shopping cart and their count from magento using any models or helpers?
推荐答案
(在会话中)获取购物车对象:
To get your cart object (in session) :
$quote = Mage::getSingleton('checkout/session')->getQuote();
然后,获取购物车中的物品列表:
Then, to get the list of items in the cart :
$cartItems = $quote->getAllVisibleItems();
然后,获取每个项目的计数:
Then, to get the count for each item :
foreach ($cartItems as $item) {
echo $item->getQty();
}
这篇关于如何使用模型在购物车中获取商品? (Magento)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文