将产品添加到购物车时更改报价中的价格:magento [英] Changing the price in quote while adding product to cart: magento
本文介绍了将产品添加到购物车时更改报价中的价格:magento的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在将该产品添加到购物车的同时更改产品价格.
I want to change the product price while add that product to cart.
怎么可能让我知道...
How its possible let me know...
推荐答案
添加一个观察者来寻找这个事件 'sales_quote_add_item'
:
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();
}
这篇关于将产品添加到购物车时更改报价中的价格:magento的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文