This is the first thing you need to do is listen to the event that was fired when the item was added to the cart. This is called checkout_cart_add_product_complete and comes from Mage/Checkout/controllers/CartController.php .
The subscription of the event that is dispatched is:
Mage::dispatchEvent('checkout_cart_add_product_complete', array( 'product' => $product, 'request' => $this->getRequest(), 'response' => $this->getResponse() ) );
We can access the product that has been added to the cart through the product variable. This means that we can evaluate whether we need to show our new message or not, based on your attribute.
The next step is to add the flash message to the page. This is controlled through sessions. There are three types of messages that you can use: success, error, and notification. Adding a message is simple:
Mage::getSingleton('core/session')->addSuccess($message); Mage::getSingleton('core/session')->addError($message); Mage::getSingleton('core/session')->addNotice($message);
source share