Magento update subtotal item -
i can't update subtotal item in cart. created module observe checkout_cart_product_add_after can subtotal price item:
$subtotal = mage::getsingleton('checkout/cart')->getquote()->getsubtotal();
but can't update this, exmaple:
$subtotal = $subtotal + 100; mage::getsingleton('checkout/session')->getquote()->setsubtotal($subtotal); mage::getsingleton('checkout/cart')->getquote()->setsubtotal($subtotal); mage::getsingleton('checkout/session')->getquote()->save(); mage::getsingleton('checkout/cart')->getquote()->save();
edit
if run in observer print_r($subtotal); exit;
correct updated subtotal. in cart page have still orginal subtotal without change.
edit 2 i'm trying run modifysubtotal function sales_quote_collect_totals_after event, can't see on cart page updated subtotal price. below code of modifysubtotal observer.php:
public function modifysubtotal(varien_event_observer $observer) { $session = mage::getsingleton('checkout/session'); $quote=$observer->getquote(); $subtotal = $quote->getbasesubtotal(); $subtotal = $subtotal +123; $quote->setbasesubtotal($subtotal); $quote->save(); $subtotal2 = $quote->getbasesubtotal(); //print_r($subtotal2);exit; }
i'll grateful tips , help.
you should observe sales_quote_collect_totals_after
.
Comments
Post a Comment