问题描述
最近几天运营发现有客户支付完订单之后直接跳转到了/checkout/cart/,通过进一步测试锁定只有非注册用户能够重现该bug。进一步查看得知是从/checkout/cart/重定向到/checkout/onepage/success/的,猜测大概是session的问题。
查看核心代码vendor/magento/module-checkout/Controller/Onepage/Success.php 第18行得知,isValid()为false,导致了重定向bug
$session = $this->getOnepage()->getCheckout();
if (!$this->_objectManager->get(\Magento\Checkout\Model\Session\SuccessValidator::class)->isValid()) {
return $this->resultRedirectFactory->create()->setPath('checkout/cart');
}
$session->clearQuote();
继续查看vendor/magento/module-checkout/Model/Session/SuccessValidator.php 30行,依次将两个return false注释分别测试锁定真正原因发现$this->checkoutSession->getLastSuccessQuoteId()为空
/**
* @return bool
*/
public function isValid()
{
if (!$this->checkoutSession->getLastSuccessQuoteId()) {
return false;
}
if (!$this->checkoutSession->getLastQuoteId() || !$this->checkoutSession->getLast

本文针对Magento平台中非注册用户支付完成后出现的重定向错误进行了详细分析,并定位到具体代码行。通过对Session验证逻辑的深入研究,找到了问题根源并提供了解决方案。
最低0.47元/天 解锁文章
2485

被折叠的 条评论
为什么被折叠?



