【问题标题】:Fatal error: Call to a member function getPayment() on a non-object in app/code/core/Mage/Paypal/Block/Express/Review.php on line 203致命错误:在第 203 行的 app/code/core/Mage/Paypal/Block/Express/Review.php 中的非对象上调用成员函数 getPayment()
【发布时间】:2012-12-30 11:35:14
【问题描述】:

在从贝宝重定向回来后,我在通过贝宝快速结账进行交易时遇到了这个错误。

我在运输方式中发现了这个错误。

我使用的是 magento 1.7 版本。

这是它给出错误的代码

 protected function _beforeToHtml()
    {
        $methodInstance = $this->_quote->getPayment()->getMethodInstance(); // here i get error
        $this->setPaymentMethodTitle($methodInstance->getTitle());
        $this->setUpdateOrderSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateOrder"));
        $this->setUpdateShippingMethodsUrl($this->getUrl("{$this->_paypalActionPrefix}/express/updateShippingMethods"));

        $this->setShippingRateRequired(true);
        if ($this->_quote->getIsVirtual()) {
            $this->setShippingRateRequired(false);
        } else {
            // prepare shipping rates
            $this->_address = $this->_quote->getShippingAddress();
            $groups = $this->_address->getGroupedAllShippingRates();
            if ($groups && $this->_address) {
                $this->setShippingRateGroups($groups);
                // determine current selected code & name
                foreach ($groups as $code => $rates) {
                    foreach ($rates as $rate) {
                        if ($this->_address->getShippingMethod() == $rate->getCode()) {
                            $this->_currentShippingRate = $rate;
                            break(2);
                        }
                    }
                }
            }

            // misc shipping parameters
            $this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod"))
                ->setCanEditShippingAddress($this->_quote->getMayEditShippingAddress())
                ->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod())
            ;
        }

        $this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit"))
            ->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder"));

        return parent::_beforeToHtml();
    }

【问题讨论】:

    标签: php paypal magento-1.7


    【解决方案1】:

    您请明确您的问题,并在您遇到错误的地方发布代码,以便我们期待解决您的问题。

    错误背后的原因可能是您在未正确初始化的对象上调用 getpayment() 方法。

    【讨论】:

    • 你好,sandeep,我已经更新了代码并写了一条评论 // 在这里我在我得到这个错误的那一行得到了错误。您需要任何进一步的信息吗?这是详细信息,我将产品添加到购物车,然后在 paypal 网站上填写信息后使用 paypal express checkout 处理,它将我重定向回我的网站,我收到此错误...
    • 使用“_quote”对象调用“getPayment()”时检查是否设置了“_quote”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-21
    • 2011-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-15
    相关资源
    最近更新 更多