关于提示We can't add this item to your shopping cart right now.

今天安装新magento 2 前台添加购物车提示 We can’t add this item to your shopping cart right now.
谷歌了这个问题,发现很多朋友都遇到过,解决方法也不同,但大部分都不可行。最后找到一个台湾朋友的博客,说确定是SERVER time zone没有设置好。以下是他的原话。

近來開發magento,用上了2.1.X的版本,對我來說是很新的嘗試。Magento從來都不應該什麼都不管、以為自己什麼都懂就衝進去做開發的。雖然知道,但有時多了經驗就會重滔覆徹的了。

話說,架設好了以後,就進行很初步的測試,誰知就出了「we can’t add this item to your shopping cart right now」這句經典錯誤。照理magento出到2.X了,沒理由會有這樣子的bug 吧? 但很顯然我是想多了。上網google這個錯誤,才發覺了原來一街都是開發者在問這個問題,而很顯然亦沒有人知道為何。有些說法是OPCACHE沒有設定好,然後有些人做了相關設定就把問題解決了。

然而更多的人就算設定好了CACHE後,問題仍然持續。更多的人當然包括小弟在內。然後找呀找,試呀試,一樣出現同樣句子。到最後得出的答案,原來是SERVER time zone未有設定好。是懶了,是這個系統太嚴緊了,是自己疏忽了。XD
—-「we can’t add this item to your shopping cart right now」 SOLUTION—-

Setup your cache and session properly, tons of stack exchange have taught you how-to, search for keyboard “OPCACHE Magento" and you will find the solution, i am not a pro, so I won’t bother it here.
Set your server timezone! Which is going to match your Magento time zone setting!

In this way, you should be able to fix the can’t add to cart problem, cheers!


但我也进行设置过,问题依然没有解决。不知道是不是我设置错误,按理说这个设置不难。请问有朋友遇到过这个问题吗?是如何解决的呢。

按照这个说明,需要把服务器的时区设置为和Magento设置的时区一致。。
我认为可能是session时间太短造成的,你把session存活时间改为84600试试。

感谢shuai哥昨晚的帮助。虽然没有解决问题,今天下午又重新安装了最新的magento 2.2.5测试这个问题。最终找到解决方法,
打开这个文件夹,
/vendor/magento/zendframework1/library/Zend/Cache/Backend
打开和编辑 file.php
搜索 ‘cache_dir’ => null,
替换成下面
‘cache_dir’ => ‘var/cache’,
问题就解决了。

这个问题困扰我很长时间,今天终于解决了。希望能帮到大家。

感谢 Moppelfett,原文在这里
https://community.magento.com/t5/Magento-2-x-Technical-Issues/Error-when-quot-Add-to-Cart-quot-Error-message-quot-We-can-t-add/td-p/49961