Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Review contents of shopping cart
 
Seiji
Jr. Member
 
Total Posts:  9
Joined:  2008-06-28
 

I’m having a heck of a time wrapping my head around all of this, and I’m just starting to get a grasp of it all.

When a customer adds a product to their cart, I need to be able to check the contents of their cart.  I’ve managed to add an observer to listen to for a checkout_cart_product_add_after event.  Here’s my code for the observer class:

class Viaero_ShoppingCart_Model_Observer extends Mage_Core_Model_Abstract {
public function verify_contents($observer) {
$order = $observer->getEvent()->getOrder();

die(var_dump($order);
}
}

The problem is that $order is NULL.  Any suggestions?

 
Magento Community Magento Community
Magento Community
Magento Community
 
LindyKyaw
Sr. Member
 
Avatar
Total Posts:  138
Joined:  2008-01-02
Los Angeles
 

When you check, the event of checkout_cart_product_add_after

Mage::dispatchEvent('checkout_cart_product_add_after', array('quote_item'=>$result'product'=>$product));
There is only QuoteItem and Product associated to the event. There is no order associated to the event.

You can only call

$observer->getEvent()->getQuoteItem(); 
$observer->getEvent()->getProduct();
 
Magento Community Magento Community
Magento Community
Magento Community
 
Seiji
Jr. Member
 
Total Posts:  9
Joined:  2008-06-28
 

Ok, that makes sense since I’m just capturing the event, so that’s not what I’m looking to do.  I’m developing a website for a wireless carrier, and I need to check when a product is added to the cart whether it’s a plan or a phone.  If they are adding a phone and don’t have a plan, then they need to be redirected to choose a plan, and visa versa.  So maybe what I’m looking to do is override the shopping cart itself?  Possibly only the ‘add’ method.  Is that correct?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top