We tried to update the product price after addto cart. I done the following code but cant get the item product price.
In app/etc/modules
<?xml version="1.0"?>
<config>
<modules>
<test_Productoptions>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
<depends>
<Mage_Checkout />
</depends>
</test_Productoptions>
</modules>
</config>
In app/code/local/test/productoptions/etc
0.0.1
Test_Productoptions_Model
<checkout_cart_product_add_after>
<observers>
<priceupdate_observer>
<type>singleton</type>
<class>test_productoptions/observer</class>
<method>updatePrice</method>
</priceupdate_observer>
</observers>
</checkout_cart_product_add_after>
</events>
</frontend>
I Write the observer in app/code/local/test/productoptions/model
<?php
class Test_Productoptions_Model_Observer
{
public function _construct()
{
}
public function getNewPrice()
{
//Your new functionality here
//
$newprice = "";
return $newprice;
}
public function updatePrice( Varien_Event_Observer $observer )
{
$quote_item = $observer->getQuoteItem();
$product = $quote_item->getProduct();
$quantity = $product->getQty();
echo $quote_item->getPrice();
die();
}
}
In this $quote_item->getPrice() is return null value. How to get the currently added product price from quote.
Best Answer
First set this code in
config.xml
You should use below method in Observer
Replace this line
$custom_price = $org_price + 15;
with your custom price logic