1

We write the observer for updating the product price while add to cart.i have write the observer but can't get item price for currently added product in cart.

In the below code, how to get the item price of currently added item.

public function updatePrice( Varien_Event_Observer $observer ) 
 {

    $event = $observer->getEvent();

}
2
1

The is a similar question here

I think what you need from there is simply this part In your Observer.php you would need something like this

public function _construct()
  {
  }

public function getNewPrice()
  {
    //Your new functionality here
    //
    $newprice = "";

    return $newprice;
  }

 public function updatePrice( Varien_Event_Observer $observer ) 
 {
    $event = $observer->getEvent();
    $quote_item = $event->getQuoteItem();
    $new_price = $this->getNewPrice();
    $quote_item->setOriginalCustomPrice($new_price);
    $quote_item->save();
  }
0
0

Use below code:

public function updatePrice( Varien_Event_Observer $observer ) 
 {
$quote = $observer->getQuote();
foreach($quote->getAllItems() as $quote_item) {
        // get items detail here
        echo $quote_item->getPrice();

}

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.