0
我試圖在下訂單後使用magento事件觀察者重新計算magento總數。我使用下面的代碼計算總數。重新計算訂單後的總計
觀察Functon
public function recalculateTotal($observer){
//var_dump($observer->getOrder()->getData());exit;
$orderModel = $observer->getOrder();
//echo "<pre>";print_r($orderModel->getData());echo "</pre>";exit;
$saveModel = Mage::getModel('sales/order')->load($orderModel->getId());
$saveModel->setSurcharge(10);
$saveModel->setBaseSurcharge(10);
$saveModel->collectTotals();
$saveModel->save();
echo "<pre>";print_r($orderModel->getData());echo "</pre>";exit;
}
事件
<global>
<events>
<sales_order_place_after>
<observers>
<order_surcharge_display>
<type>singleton</type>
<class>surcharge/observer</class>
<method>recalculateTotal</method>
</order_surcharge_display>
</observers>
</sales_order_place_after>
</events>
</global>
但沒有什麼變化,請幫助。
感謝您的回放@Siarhey但這不是iw的工作原理螞蟻在下訂單後換個宏。 – Zaheerabbas
答覆已更新 –