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/
相关推荐
magento 购物车预览cartview
Magento 添加到购物车矩阵 显示所有可配置的产品颜色和尺寸组合以及可用库存,并允许将产品大量添加到购物车。
Ajax-magento2-ajax-cart-quick.zip,magento 2 ajax购物车扩展插件提供舒适的购物体验。客户可以很容易地选择可配置的选项并在弹出窗口中编辑项目,而不会浪费重新加载页面的时间。,ajax代表异步javascript和xml。它...
Ajax-magento2-ajax-cart.zip,ajax add to cart for extension magento 2提供了通过ajax弹出窗口将产品添加到购物车的主要功能。它通过允许客户从产品列表页面将任何产品类型添加到购物车,显著改善了用户体验。,...
magento通过产品名称获取产品id提示代码
magento ajax购物车,更多插件请留意wangdz.cn
Magento导入导出产品插件 编辑csv表格导入产品 Import Products categories multiple images and custom options 1 1 2 tgz 与官方插件一样
Magetop的Magento 2 Ajax购物车扩展Magetop开发的Magento 2 Ajax购物车扩展程序具有通过AJAX弹出窗口向购物车添加产品的主要功能。 通过允许客户直接从产品列表页面将任何产品类型添加到购物车,它可以显着改善用户...
Magepow的Magento 2 Sticky添加到购物车扩展程序为产品页面提供了方便的摇杆,可帮助客户快速将产品添加到购物车而无需返回顶部 细节 Magento 2 Sticky添加到购物车Magepow免费提供,可帮助商店所有者使购物车始终...
如何给产品描述里的关键字、字词批量添加链接?我想大家一直在的这样的插件。说实话,我也找了很久,也没有找到。可是由于需要,不得不自己开发一个这样的插件。并支持到Magento1.6.2 说明请查看:...
magento站点首页显示新产品及产品数量,可在block块中设置产品数量
为什么magento产品不改变“缺货”尽管数量已经低于最低
MB_属性 在 Magento 1.x 中为购物车价格规则/优惠券添加属性的简单模块。... 请参阅此处的完整讨论:magento.stackexchange.com/questions/67949/add-attribute-to-shopping-cart-price-rule-coupon/
无需进入产品产品详情页就可以预览产品图片,商店访问者也可以通过单击项目图片进入产品页面而没有任何问题(禁止用作商业用途)
magento产品名称及描述批量修改sql
As a Magento specialist he has achieved all the Magento certifications. He is an active member of the community and has been recognized as a Magento Master for 2017. He is the Chief Operating Officer...
Magento1.7测试可用 批量产品多图上传 包含上传样本
此模块为Magento购物车价格规则功能提供了2个新操作: 根据当地条件向客户提供礼品产品 每次达到阈值时向客户提供礼品产品(例如,购物车中每30 $) 对于每个购物车价格规则,管理员可以定义授权的礼品产品的数量...
Block items can include any content that Magento CMS can involve Powerful block view scheduler Per-category and per-store view aheadWorks Market Segmentation Suite extension integration Enabling/...
Get a detailed insight into the structure of Magento Learn about event/observer-driven modules Get a hands-on introduction to custom shipping and payment methods ☆ 出版信息:☆ [作者信息] Branko ...