更新cart item的price

来源:互联网 发布:php房屋租赁管理系统 编辑:程序博客网 时间:2024/05/17 08:10
            $quote = Mage::getModel('checkout/cart')->getQuote();            $_cartItems = $quote->getAllVisibleItems();                        foreach ($_cartItems as $_cartItem) {                $productId = $_cartItem->getData('product_id');                                                                         $_cartItem->setOriginalCustomPrice($newprice);            }            $quote->collectTotals();            $quote->save();


注意:如果使用sales_quote_add_item这个observer,代码如下

public function updatePrice( $observer ){        $event = $observer->getEvent();        $quote_item = $event->getQuoteItem();        $new_price = 200;        $quote_item->setOriginalCustomPrice($new_price);        $quote_item->setTotalPrice(350);}

原创粉丝点击