I want to change each and every selected bundle items price on addtocart

How can I do this.

At present I am doing like below :

$item = $observer->getQuoteItem();
if ($item->getParentItem()) {$item = $item->getParentItem();}

By doing above, it only change Parent Bundle product Price.

Please check screenshot :

enter image description here

So is there any posibility to change price of bundle items with custom price which will display properly even after order place in order view page. I have go through the code and find that "Bundle Items's" price are saved in infobuyrequest.

$sel_bundle_options = $item->getProduct()->getTypeInstance(true)->getOrderOptions($item->getProduct());

So is it possible to change price directly into that ? But after placing an order if we check on order view pages,it will display.

  • I would recommend using a total model instead of wasting time on editing the buyrequest.
    – adjco
    Oct 6 '16 at 21:48
  • Can you please elaborate ?
    – Krupali
    Oct 7 '16 at 5:22
  • Can someone Please help on this issue? Mar 21 '17 at 18:09
  • @MagentoTeam please look my answer.
    – Krupali
    Apr 4 '17 at 11:33

You can do below code while adding product to the cart.

$cart = Mage::helper('checkout/cart')->getCart()->getQuote()->getAllItems();
$price = '';
foreach ($cart as $i)
  if ($i->getId() == '') // Dont getting id for currently adding bundle item.
     $options = $i->getOptions();
     foreach ($options as $option)
        if ($option->getCode() == 'bundle_selection_attributes')
           $unserialized = unserialize($option->getValue());
           $price = 10; // YOUR CUSTOM PRICE
           $unserialized['price'] = number_format($price, 2, '.', ',');
     catch (Exception $e)

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.