Magento2: Can not add product to cart (logged in customer)

Created on 20 Jun 2016  路  10Comments  路  Source: magento/magento2

Steps to reproduce

i'm using magento 2.0.7

  1. login to a customer account
  2. try to add something to shopping cart and place an order
  3. after order is saved go back to store and try to add something else to shopping cart.
  4. it return error message: We can't add this item to your shopping cart right now.
  5. If i logout and login back i can add the product to shopping cart and place order as normal
needs update

Most helpful comment

@Tosse
I found the solution
Go to
/vendor/magento/zendframework1/library/Zend/Cache/Backend
and edit the file.php
Search for 'cache_dir' => null,
and replace it with
'cache_dir' => 'var/cache',
DONE!
For us it worked well.

All 10 comments

@hungvt
Unfortunately, I was not able to reproduce the issue you described.
Could you please provide more information? Like versions of PHP, MySQL and web server.
Also, it can be helpful if you describe settings of your Magento instance: was it the fresh install or upgrade from the previous version?
Do you have many store views? Maybe some other settings.

According to contributor guide, tickets without response for two weeks should be closed.
Please feel free to reopen if it's needed.

I get the same error Message: We can't add this item to your shopping cart right now
Just installed the latest magento 2.1.2 CE with Sample data.... All Indexes and Cache are marked Green, okay.
Strange Thing, if you are in the category overview, you Can add the Item and place an Order.
Only if you are into the Item Detail view, you get this error message.
No matter if you are logged in as customer or not...
Cheers Tosse

An, sorry.... Requested Information....

PHP 7.0.10
MySQL 5.7.15
Apache
Datenbank-Client Version: libmysql - mysqlnd 5.0.12-dev

@tosse
Same problem here.
I can't believe MAGENTO 2 is so buggy.
Can anyone help?

@hungvt Have you any Php error logs ?

[2017-03-05 07:56:27] main.CRITICAL: Zend_Cache_Exception: Could not determine temp directory, please specify a cache_dir manually in /www/htdocs/w0159efc/vendor/magento/zendframework1/library/Zend/Cache.php:209
Stack trace:

0 /www/htdocs/w0159efc/vendor/magento/zendframework1/library/Zend/Cache/Backend.php(217): Zend_Cache::throwException('Could not deter...')

1 /www/htdocs/w0159efc/vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php(130): Zend_Cache_Backend->getTmpDir()

2 /www/htdocs/w0159efc/vendor/magento/zendframework1/library/Zend/Cache.php(153): Zend_Cache_Backend_File->__construct(Array)

3 /www/htdocs/w0159efc/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('File', Array, false, false)

4 /www/htdocs/w0159efc/vendor/magento/zendframework1/library/Zend/Locale/Data.php(328): Zend_Cache::factory('Core', 'File', Array, Array)

5 /www/htdocs/w0159efc/vendor/magento/zendframework1/library/Zend/Locale/Format.php(519): Zend_Locale_Data::getList('en_US', 'symbols')

6 /www/htdocs/w0159efc/vendor/magento/zendframework1/library/Zend/Filter/LocalizedToNormalized.php(100): Zend_Locale_Format::isNumber('1', Array)

7 /www/htdocs/w0159efc/vendor/magento/module-checkout/Controller/Cart/Add.php(90): Zend_Filter_LocalizedToNormalized->filter('1')

8 /www/htdocs/w0159efc/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Checkout\Controller\Cart\Add->execute()

9 /www/htdocs/w0159efc/var/generation/Magento/Checkout/Controller/Cart/Add/Interceptor.php(26): Magento\Checkout\Controller\Cart\Add\Interceptor->___callPlugins('execute', Array, Array)

10 /www/htdocs/w0159efc/vendor/magento/framework/App/Action/Action.php(102): Magento\Checkout\Controller\Cart\Add\Interceptor->execute()

11 /www/htdocs/w0159efc/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))

12 /www/htdocs/w0159efc/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Checkout\Controller\Cart\Add\Interceptor->___callParent('dispatch', Array)

13 /www/htdocs/w0159efc/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')

14 /www/htdocs/w0159efc/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))

15 /www/htdocs/w0159efc/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))

16 /www/htdocs/w0159efc/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...')

17 /www/htdocs/w0159efc/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))

18 /www/htdocs/w0159efc/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))

19 /www/htdocs/w0159efc/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')

20 /www/htdocs/w0159efc/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))

21 /www/htdocs/w0159efc/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))

22 /www/htdocs/w0159efc/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...')

23 /www/htdocs/w0159efc/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))

24 /www/htdocs/w0159efc/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))

25 /www/htdocs/w0159efc/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-...')

26 /www/htdocs/w0159efc/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))

27 /www/htdocs/w0159efc/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))

28 /www/htdocs/w0159efc/var/generation/Magento/Checkout/Controller/Cart/Add/Interceptor.php(39): Magento\Checkout\Controller\Cart\Add\Interceptor->___callPlugins('dispatch', Array, Array)

29 /www/htdocs/w0159efc/vendor/magento/framework/App/FrontController.php(55): Magento\Checkout\Controller\Cart\Add\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

30 /www/htdocs/w0159efc/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))

31 /www/htdocs/w0159efc/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)

32 /www/htdocs/w0159efc/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...')

33 /www/htdocs/w0159efc/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))

34 /www/htdocs/w0159efc/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))

35 /www/htdocs/w0159efc/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')

36 /www/htdocs/w0159efc/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain{closure}(Object(Magento\Framework\App\Request\Http))

37 /www/htdocs/w0159efc/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))

38 /www/htdocs/w0159efc/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...')

39 /www/htdocs/w0159efc/vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain{closure}(Object(Magento\Framework\App\Request\Http))

40 /www/htdocs/w0159efc/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

41 /www/htdocs/w0159efc/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...')

42 /www/htdocs/w0159efc/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))

43 /www/htdocs/w0159efc/app/code/TemplateMonster/SiteMaintenance/Model/PageCache/App/FrontController/BuiltinPlugin.php(30): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

44 /www/htdocs/w0159efc/vendor/magento/framework/Interception/Interceptor.php(142): TemplateMonster\SiteMaintenance\Model\PageCache\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))

45 /www/htdocs/w0159efc/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)

46 /www/htdocs/w0159efc/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))

47 /www/htdocs/w0159efc/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()

48 /www/htdocs/w0159efc/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))

49 {main} [] []

@Tosse
I found the solution
Go to
/vendor/magento/zendframework1/library/Zend/Cache/Backend
and edit the file.php
Search for 'cache_dir' => null,
and replace it with
'cache_dir' => 'var/cache',
DONE!
For us it worked well.

Thanks for the workaround @Moppelfett, but I still don't get how could this happen all of the sudden, without changing a setting or other stuff? Everything was working fine until a customer reported that he cannot add products into the cart and I tracked it down to this.

main.CRITICAL: Zend_Cache_Exception: Could not determine temp directory, please specify a cache_dir manually

Could this be related to a server update? We're also using Redis and Varnish for caching - can it be related?

@robmagento
I am not a coder but I can tell you that we had this issue right from the start after installing Magento.
Maybe someone else can answer you your question about the server update.

Was this page helpful?
0 / 5 - 0 ratings