The way to do it is add an observer which looks for this event 'sales_quote_add_item'
:
<events>
<sales_quote_add_item>
<observers>
<priceupdate_observer>
<type>singleton</type>
<class>mymodule/observer</class>
<method>updatePrice</method>
</priceupdate_observer>
</observers>
</sales_quote_add_item>
</events>
The observer should have a method which does something like this:
public function updatePrice($observer) {
$event = $observer->getEvent();
$quote_item = $event->getQuoteItem();
$new_price = <insert logic>
$quote_item->setOriginalCustomPrice($new_price);
$quote_item->save();
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…