Magento - 如何检查产品是否已从购物车中删除
我正在编写一个小模块,它将自动将产品添加到购物车(基于某些标准)。但是,如果用户随后从购物车中删除该自动产品,我需要知道,以便我不会在当前会话中再次添加它。
购物车对象是否包含任何可以告诉我产品是否已从购物车中删除的内容?
I'm writing a small module that will add a product to the cart automatically (based on certain criterias). However if the user subsequently removes that automatic product from the cart I need to know so that I don't add it again in the current session.
Does the cart object hold anything that can tell me if a product has been removed from the cart already?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Magento 不会记录哪些项目已被删除,您必须自己做。首先监听一个事件;
app/local/YOURMODULE/etc/config.xml
app/local/YOURMODULE/Model/Observer.php
创建一个扩展
Mage_Core_Model_Session_Abstract
的会话类并用它来存储您在上述观察者中收集的产品ID。然后,您可以引用该会话对象(由Mage::getSingleton()
调用)来查看购物车中曾经有哪些产品。Magento doesn't keep record of which items have been removed, you will have to do that yourself. Start by listening for an event;
app/local/YOURMODULE/etc/config.xml
app/local/YOURMODULE/Model/Observer.php
Create a session class that extends
Mage_Core_Model_Session_Abstract
and use it to store the product IDs you collect in the above observer. You can then refer to that session object (called byMage::getSingleton()
) to see what products used to be in the cart.是的,您可以像这样获取购物车中的当前商品:-
此链接可能有帮助
http://www.magentocommerce.com/boards/viewthread/19020/
yes you can get current items in cart like this:-
This link may helpful
http://www.magentocommerce.com/boards/viewthread/19020/