Reputation: 2907
I would like to know if anyone can answer the following question.
How can you check when an item has been added to the cart?
I need to do some highlighting when a item has been added, but i can't figure out how.
Anyone know?
I'm rather new at magento, so sorry for my noobish question :)
Upvotes: 2
Views: 1907
Reputation:
You can retrieve the cart items like this :
$items = Mage::getSingleton('checkout/cart')->getItems();
foreach($items as $item) {
$product = Mage::getModel('catalog/product')
->loadByAttribute('sku',$item->getSku());
//...
}
or another way would be to handle the product add to cart event, maybe it fits your needs better, as Mage will do this :
Mage::dispatchEvent('checkout_cart_product_add_after',
array('quote_item' => $result, 'product' => $product));
right after adding the product to the cart.
Upvotes: 4