0

Generic error when adding product to cart: "We can't add this item to your shopping cart right now."

Exception log gives this error:

[2018-02-16 15:40:31] main.CRITICAL: exception 'Exception' with message 'Recoverable Error: Object of class Magento\Catalog\Model\Product\Interceptor could not be converted to string in /home/domain/public_html/store/vendor/magento/module-checkout/Model/Cart.php on line 357' in /home/domain/public_html/store/vendor/magento/framework/App/ErrorHandler.php:61
Stack trace:
#0 /home/domain/public_html/store/vendor/magento/module-checkout/Model/Cart.php(357): Magento\Framework\App\ErrorHandler->handler(4096, 'Object of class...', '/home/domain/p...', 357, Array)
#1 /home/domain/public_html/store/var/generation/Magento/Checkout/Model/Cart/Interceptor.php(115): Magento\Checkout\Model\Cart->addProduct(Object(Magento\Catalog\Model\Product\Interceptor), Array)
#2 /home/domain/public_html/store/vendor/magento/module-checkout/Controller/Cart/Add.php(103): Magento\Checkout\Model\Cart\Interceptor->addProduct(Object(Magento\Catalog\Model\Product\Interceptor), Array)
#3 /home/domain/public_html/store/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Checkout\Controller\Cart\Add->execute()
#4 /home/domain/public_html/store/var/generation/Magento/Checkout/Controller/Cart/Add/Interceptor.php(26): Magento\Checkout\Controller\Cart\Add\Interceptor->___callPlugins('execute', Array, Array)
#5 /home/domain/public_html/store/vendor/magento/framework/App/Action/Action.php(102): Magento\Checkout\Controller\Cart\Add\Interceptor->execute()
#6 /home/domain/public_html/store/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#7 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Checkout\Controller\Cart\Add\Interceptor->___callParent('dispatch', Array)
#8 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Cart\Add\Interceptor), Array, 'contextPlugin')
#9 /home/domain/public_html/store/vendor/magento/module-store/App/Action/Plugin/Context.php(106): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#10 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\Action\Plugin\Context->aroundDispatch(Object(Magento\Checkout\Controller\Cart\Add\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#11 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Cart\Add\Interceptor), Array, 'storeCheck')
#12 /home/domain/public_html/store/vendor/magento/module-store/App/Action/Plugin/StoreCheck.php(44): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#13 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\Action\Plugin\StoreCheck->aroundDispatch(Object(Magento\Checkout\Controller\Cart\Add\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#14 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Cart\Add\Interceptor), Array, 'customer-app-ac...')
#15 /home/domain/public_html/store/vendor/magento/module-customer/Model/App/Action/ContextPlugin.php(61): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#16 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Customer\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Checkout\Controller\Cart\Add\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#17 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Cart\Add\Interceptor), Array, 'weee-app-action...')
#18 /home/domain/public_html/store/vendor/magento/module-weee/Model/App/Action/ContextPlugin.php(112): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#19 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Weee\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Checkout\Controller\Cart\Add\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#20 /home/domain/public_html/store/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Cart\Add\Interceptor), Array, 'tax-app-action-...')
#21 /home/domain/public_html/store/vendor/magento/module-tax/Model/App/Action/ContextPlugin.php(91): Magento\Checkout\Controller\Cart\Add\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#22 /home/domain/public_html/store/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Tax\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Checkout\Controller\Cart\Add\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#23 /home/domain/public_html/store/var/generation/Magento/Checkout/Controller/Cart/Add/Interceptor.php(39): Magento\Checkout\Controller\Cart\Add\Interceptor->___callPlugins('dispatch', Array, Array)
#24 /home/domain/public_html/store/vendor/magento/framework/App/FrontController.php(55): Magento\Checkout\Controller\Cart\Add\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#25 /home/domain/public_html/store/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#26 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#27 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'requestPreproce...')
#28 /home/domain/public_html/store/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#29 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#30 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#31 /home/domain/public_html/store/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#32 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#33 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#34 /home/domain/public_html/store/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#35 /home/domain/public_html/store/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#36 /home/domain/public_html/store/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#37 /home/domain/public_html/store/vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#38 /home/domain/public_html/store/vendor/magento/framework/Interception/Interceptor.php(142): Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#39 /home/domain/public_html/store/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#40 /home/domain/public_html/store/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#41 /home/domain/public_html/store/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#42 /home/domain/public_html/store/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#43 {main} [] []
  • check your file vendor/magento/module-checkout/Model/Cart.php with line No. 357. I think you have echo some value there. – Suresh Chikani Feb 16 '18 at 19:14
  • Line 357 says: $smsg .= "productInfo: " . $productInfo . "\n"; and the lines before and after are empty. the line above is $smsg = "addProduct\n"; and the line below is $product = $this->_getProduct($productInfo); – Indigo Viking Feb 16 '18 at 21:06
0

You need to do this things.

  1. Copy vendor/magento/module-checkout/Model/Cart.php file from default magento

  2. Paste that file in your this magento at same location. vendor/magento/module-checkout/Model/Cart.php

  3. run this command from CLI.

    php bin/magento cache:clean
    php bin/magento cache:flush 
    
| improve this answer | |

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.