(1) app/code/local/Kodematix/Testing/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Kodematix_Testing>
<version>0.1.0</version>
</Kodematix_Testing>
</modules>
<frontend>
<events>
<checkout_cart_product_add_after>
<observers>
<testing>
<class>testing/observer</class>
<method>cartProductAddAfter</method>
</testing>
</observers>
</checkout_cart_product_add_after>
</events>
</frontend>
</config>
(2) app/code/local/Kodematix/Testing/Model/Observer.php
class Kodematix_Testing_Model_Observer{
public function cartProductAddAfter($observer)
{
if(Mage::getSingleton('customer/session')->isLoggedIn()){
$customer = Mage::getSingleton('customer/session')->getCustomer();
$disprice = $customer['discount'];
$product = $observer->getEvent()->getProduct();
$currentItem = $observer->getEvent()->getQuoteItem();
$event = $observer->getEvent();
$quote_item = $event->getQuoteItem();
$price = $product->getPrice();
// Discounted off
$percentDiscount = $disprice/100;
$new_price = $price - ($price * $percentDiscount);
$quote_item->setOriginalCustomPrice($new_price);
$quote_item->save();
Mage::getSingleton('core/session')->addSuccess('Your '.$disprice.'% Apply this Product');
}
}
}