获取注销页面中的购物车商品数量
如何获取注销页面中的购物车项目数量,我尝试使用以下代码,它在 cart.phtml 中工作,但在 logout.phtml 中不起作用,
$cart = Mage::getSingleton('checkout/cart')->getItemsCount();
echo 'cart items count: ' . $cart;
$cart = Mage::helper('checkout/cart')->getItemsCount();
echo 'cart items count: ' . $cart;
$cart = Mage::helper('checkout/cart')->getCart()->getItemsCount();
echo 'cart items count: ' . $cart;
我想因为它已经注销,所以无法再访问,我应该尝试使用 cookie 获取该信息吗?
预先感谢您的任何帮助
How can I get the number of cart items in logout page, I try to use the following code, it works in cart.phtml but not in logout.phtml
$cart = Mage::getSingleton('checkout/cart')->getItemsCount();
echo 'cart items count: ' . $cart;
$cart = Mage::helper('checkout/cart')->getItemsCount();
echo 'cart items count: ' . $cart;
$cart = Mage::helper('checkout/cart')->getCart()->getItemsCount();
echo 'cart items count: ' . $cart;
I suppose since it is already logged out it doesn't get access any more, should I try to get that information using cookies?
Thanks in advance for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我用这个:
i use this :
好吧,我在我的
mini.login.phtml
中使用它,我把它放在页面的页脚中,好消息是它确实可以获取购物车中的商品数量。坏消息是,添加产品后它不会立即更新,因此我需要刷新缓存。
Well I use
in my
mini.login.phtml
which I put in the footer of my pages and the good news is it does get the item count in the cart. The bad news is, it does not update immediately after I add a product, so I need to refresh the cache.这是声明并指向您的 getItemsCount();
为什么需要两行才能说出第三行代码?并不是刻薄,只是询问。
我想说的是:为什么不使用这个。
一次而不是用更少的信息陈述同一件事两次。
This is stated and points to your getItemsCount();
Why does this need two lines to just say the third line of code? Not trying to be mean just asking.
What im saying is: Why not use this.
Once instead of stating the same thing twice with less information.