我有这样的观察者
<events>
<sales_quote_add_item>
<observers>
<reservation_observer_order_save_before1>
<type>singleton</type>
<class>Mageec_Total_Model_Observer</class>
<method>updatePrice</method>
</reservation_observer_order_save_before1>
</observers>
</sales_quote_add_item>
</events>
函数 updatePrice 如下:
public function updatePrice($observer){
$event = $observer->getEvent();
$quote_item = $event->getQuoteItem();
if ($quote_item->getProductType() == "virtual"){
$new_price = (float)$quote_item->getProduct()->getPrice();
$quote_item->setOriginalCustomPrice($new_price);
$qty = Mage::getSingleton('checkout/cart')->getSummaryQty(); //return 0
$qty = $quote_item->getQty(); //return 0 too
Mage::log(print_r($qty,true));
$quote_item->setTotalPrice( $new_price * $qty );
}
}
我无法获得购物车数量或至少报价项目数量。我认为这是因为这个观察者在购物车对象被填充之前执行。那么在这种情况下我在哪里可以获得数量?