magento - Magento 管理员中未显示已取消的 Paypal 订单

标签 magento paypal

我已经配置了一个 Magento 1.9 社区商店,所有通过 Paypal 或其他支付方式(如货到付款)支付的订单都显示在后端。

但是,当我选择 Paypal 作为网关结账时,在 Paypal 页面上取消我的订单并返回网站 - 我的订单没有显示在后台。它不应该显示为已取消的订单吗。

由于这是一家从 Shopify 迁移过来的商店,我们不得不手动创建大约 100 个订单并手动更改数据库中的日期。这可能是这种意外行为的原因吗?

编辑 1:即使 paypal 窗口关闭而不是像许多答案建议的那样单击取消,网格中也不会显示订单信息。

最佳答案

这是显而易见的,因为当您(作为客户)在 PayPal 支付页面取消订单时,它会在重定向到商店之前自动销毁(取消设置)订单和订单报价 - 不要与著名的混淆:Cancelled Order,顾名思义,显示实际已完成然后取消的实际订单。

根据您使用的 PayPal 方法,可以区别对待。

在标准的 PayPal 中,您可以在这个 Controller 中找到它:

\magento\app\code\core\Mage\Paypal\controllers\StandardController.php

当你取消订单时,cancelAction(),它首先取消订单:

    public function cancelAction()
{
    $session = Mage::getSingleton('checkout/session');
    $session->setQuoteId($session->getPaypalStandardQuoteId(true));
    if ($session->getLastRealOrderId()) {
        $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
        if ($order->getId()) {
            $order->cancel()->save();
        }
        Mage::helper('paypal/checkout')->restoreQuote();
    }
    $this->_redirect('checkout/cart');
}

然后 redirectAction() 在重定向 repo 物车页面之前取消设置引号:

    public function redirectAction()
{
    $session = Mage::getSingleton('checkout/session');
    $session->setPaypalStandardQuoteId($session->getQuoteId());
    $this->getResponse()->setBody($this->getLayout()->createBlock('paypal/standard_redirect')->toHtml());
    $session->unsQuoteId();
    $session->unsRedirectUrl();
}

另一方面,在 PayPal Express 中,取消操作是在这个 Controller 中触发的:

\app\code\core\Mage\Paypal\Controller\Express\Abstract.php

    public function cancelAction()
{
    try {
        $this->_initToken(false);
        // TODO verify if this logic of order cancelation is deprecated
        // if there is an order - cancel it
        $orderId = $this->_getCheckoutSession()->getLastOrderId();
        $order = ($orderId) ? Mage::getModel('sales/order')->load($orderId) : false;
        if ($order && $order->getId() && $order->getQuoteId() == $this->_getCheckoutSession()->getQuoteId()) {
            $order->cancel()->save();
            $this->_getCheckoutSession()
                ->unsLastQuoteId()
                ->unsLastSuccessQuoteId()
                ->unsLastOrderId()
                ->unsLastRealOrderId()
                ->addSuccess($this->__('Express Checkout and Order have been canceled.'))
            ;
        } else {
            $this->_getCheckoutSession()->addSuccess($this->__('Express Checkout has been canceled.'));
        }
    } catch (Mage_Core_Exception $e) {
        $this->_getCheckoutSession()->addError($e->getMessage());
    } catch (Exception $e) {
        $this->_getCheckoutSession()->addError($this->__('Unable to cancel Express Checkout.'));
        Mage::logException($e);
    }

    $this->_redirect('checkout/cart');
}

它在同一个地方取消设置所有内容。

因此,在您的情况下,如果您需要保留报价(我想这是您在自定义模块中一直在利用的内容),则必须更改 PayPal 模块的这种行为。

请记住,如果您打算这样做,请不要修改原始核心文件,而是在您的自定义模块中扩展这些类并在那里应用您的更改。

关于magento - Magento 管理员中未显示已取消的 Paypal 订单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31340484/

相关文章:

magento - 自动将简单添加到可配置

transactions - 如何使用一些 API 下载 Paypal 交易

python - django paypal paypalrestsdk - 如何执行付款?没有返回 HttpResponse 对象

php - 这段更新 Paypal 按钮的代码有什么问题?我得到 "buttontype invalid error"

php - 注册后是否可以更改定期付款金额?

HTTP 上的 Paypal IPN 无法正常工作

mysql - 数据库版本更改后,不会自动使用索引

php - Magento 2.2 Paypal 付款方式选项未显示在结帐中

php - 覆盖 Magento GetPrice 函数

mysql - 如何处理 200 万件产品