why this error is showing "We can't add this item to your shopping cart right now." during add bundle product in cart in Magento 2.1?

I will change price of simple product in cart through observer,it will change successfully.This product is also part of bundle product.When we add this product in cart it display error We can't add this item to your shopping cart right now.below is my observer code.Please tell me how to solve it in magento 2.1?

public function execute(Observer $observer)
    /** @var $item \Magento\Quote\Model\Quote\Item */
    $item = $observer->getEvent()->getQuoteItem();
    if ($item->getProduct()->getTypeId() != Type::TYPE_BUNDLE  ) {
        foreach ($item->getQuote()->getAllItems() as $bundleitems) {
            /** @var $bundleitems\Magento\Quote\Model\Quote\Item */
            //Skip the bundle product
            if ($bundleitems->getProduct()->getCategoryId() =='6') {

    return $this;


public function execute(Observer $observer)
    $quote_item = $observer->getEvent()->getQuoteItem();
    $price = 100; //set your price here

This works for me. It will update product price for all types of products.

Since you did not provide your observer code, It hard to find out the reason for the error.

You can try to implement product type checking and change your code in observer accordingly.

The code you have written in observer may work only for simple product's add to cart operation. The observer code may need to change for Bundle and other products types.

Thank you

Similar questions

Magento 2 - How to remove the price of each bundle product option in the shopping cart, order confirmation, review your cart page, etc
I would like to remove the price from the bundle product options in the entire site. The place I have noticed that get displayed are: Things I have tried: I created a new module and overrode \Magento\Bundle\Helper\Catalog\Product\Configuration: ZEndertech\BundleExtended\Helper\Catalog\Product\Configuration.php I cleared the cache, but the price sti...
Bundle item inside a bundle item
Is it possible to put a bundle item inside another bundle item? i have 2 products, each with their own options.. lets call it product A and B but the two items are compatible, You can insert A into B, but as i said A has its own options. is this possible in magento? or do i need an extension for it?
Magento success page ( is showing weird message (Item has been added to your shopping cart)
The code message is shown between 'Your order has been received' and 'Thank you for your purchase'. The template success.phtml looks like this: Why is this showing this message? What could be going wrong? Where I should look for?
Magento Upgrade 1.5.1 to 1.9.1 now Cannot add the item to shopping cart
I upgraded my Magento platform and everything is working in the admin and the front end except the shopping cart. Here is my exception log. When I try to add an item to cart, the cart won't add the product. I upgraded everything on the front end but am using the 1.5.1 database with some columns added to the salescoupon table 21 {main}
How can get the bundle item of a bundle product in magento
I have a bundle product and I have added 3 bundle items (of type checkboxes) to it through the admin panel. 2 of the bundle item have only one selection in it, while the third one has 7 selections(each of which are simple products). Now i have a situation in which i need to display the names of simple products that i have added to the third bundle ...
Magento 2: getting error for all pages We can't create the Wish List right now
php bin/magento setup:upgrade display error on frontend We can't create the Wish List right now.

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.