[英]Error in plugin for WooCommerce
I have recently started to write plugin for woocommerce and everything worked flawlessly before I tried to hook the extension to the system . 我最近开始为woocommerce编写插件, 在尝试将扩展连接到系统之前 ,一切都顺利进行了 。
I have a following code inside my class . 我班上有以下代码 。
function add_gateway($methods)
{
$methods[] = 'Rentalbloom_WSPay';
return $methods;
}
add_filter('woocommerce_payment_gateways', 'add_gateway');
Class has constructor defined as a public function __contruct()
so it shouldn't have problems with the access, but when I try to run this I get the following error. 类的构造函数定义为
public function __contruct()
因此访问应该没有问题,但是当我尝试运行此函数时,出现以下错误。
Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION
and the error points to the add_filter line written above. Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION
,并且错误指向上面编写的add_filter行。
I don't know if this is relevant, but I'm using a PHP version 5.3 on the APMPPS stack on the OS X. 我不知道这是否相关,但是我在OS X的APMPPS堆栈上使用的是PHP版本5.3。
public function __contruct()
has a typo should be con s truct Soo.. public function __construct()
public function __contruct()
有一个错字应该是骗子小号 truct洙.. public function __construct()
You also mentioned 你还提到
I have a following code inside my class.
我的课内有以下代码。
You need to ensure that filters sit outside of the class scope. 您需要确保过滤器位于类范围之外。
So move add_filter('woocommerce_payment_gateways', 'add_gateway');
因此,移动
add_filter('woocommerce_payment_gateways', 'add_gateway');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.