简体   繁体   English

IWD Onepage Checkout的Magento致命错误

[英]Magento fatal error with IWD Onepage Checkout

I am using magento one page checkout for the quick checkout process. 我正在使用magento one page checkout进行快速结账流程。

It is throwing fatal error upon adding product to cart. 将产品添加到购物车时会产生致命错误。 In j2t ajax and in header cart area its showing fatal error but after reloading the page error gone and product added to shopping cart. 在j2t ajax和标题购物车区域显示致命错误但重新加载页面错误消失后,产品添加到购物车。

In PHP error log shows following error 在PHP中,错误日志显示以下错误

PHP Fatal error:  Call to a member function addLink() on a non-object in /home/public_html/app/code/community/IWD/Opc/Block/Links.php on line 17

On line 17 在第17行

$parentBlock->addLink($text, 'onepage', $text, true, array('_secure'=>true), 60, null, 'class="top-link-checkout"');

I've tried to disable ajax cart and also Compilation to disabled but its still throwing error. 我已经尝试禁用ajax购物车,并且还禁用了编译,但它仍然抛出错误。

Any idea why its showing error? 知道为什么会出现错误吗?

Thank you in advance :) 先感谢您 :)

I solved this issue by myself. 我自己解决了这个问题。 Thanks anyway. 不管怎么说,还是要谢谢你。

If anyone have this issue. 如果有人有这个问题。 Here is the Solution for it 这是它的解决方案

Go to: /Magento folder/app/code/community/IWD/Opc/Block/Links.php 转到:/ Magento文件夹/ app / code / community / IWD / Opc / Block / Links.php

Find: 找:

if (Mage::helper('opc')->isEnable()){
        $parentBlock->addLink($text, 'onepage', $text, true,     array('_secure'=>true), 60, null, 'class="top-link-checkout"');
    }
else{
        $parentBlock->addLink($text, 'checkout', $text, true,     array('_secure'=>true), 60, null, 'class="top-link-checkout"');
    }

    return $this;
}

Replace it with: 替换为:

if ($parentBlock = $this->getParentBlock()) {
         $text = $this->__('Checkout');
         $parentBlock->addLink($text, 'checkout', $text, true, array(), 60, null, 'class="top-link-checkout"');
     }
     return $this;
 }

Clear cache and cookies and you're done :) 清除缓存和cookie,你就完成了:)

A slightly better approach (until IWD fixes this, that is) is do do what Muk suggested and to just wrap that whole block around in an "is_object" check. 一个稍微好一点的方法(直到IWD解决这个问题,就是这样)是做Muk建议的,并且只是在“is_object”检查中包裹整个块。

if (is_object($parentBlock)) {
  $text = $this->__('Checkout');
  if (Mage::helper('opc')->isEnable()){
    $parentBlock->addLink($text, 'onepage', $text, true, array('_secure'=>true), 60, null, 'class="top-link-checkout"');
  } else {
    $parentBlock->addLink($text, 'checkout', $text, true, array('_secure'=>true), 60, null, 'class="top-link-checkout"');
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM