Event change price in cart Magento


In Magento, event been used a lot. Event in Magento is very strong.

If you want change price in cart of Magento, but not is add product to cart. Simple, let’s using event..

Following, I will create demo a event:

  • Initialization event in config.xml
  • Using event name: sales_quote_add_item
  • Using function: updateProductCartPrice




            <!--event when addto cart-->



                    <Test_ Addcart >


                        <class>Test_Addcart _Model_Observers</class>








In Observers.php file. My url: app/code/local/Test/Addcart/Model/Observers.php

Create a function updateProductCartPrice have content:

  • priceChange: new price


public function updateProductCartPrice($observer)


        $item           = $observer->getQuoteItem();

        $pro                               = ( $item->getParentItem() ? $item->getParentItem() : $item );

        $priceChange            = 3500;





Ok. So, price will change in cart after load again page.




About Author

Là một developer rất ham chơi nhưng không ham hố, không ham chơi nhưng rất thích cầm đầu...

Comments are closed.

%d bloggers like this: