问题描述
我正在为WooCommerce创建一个自定义支付网关,但是我正在努力在管理区域中显示设置。
我遵循了类似的教程:
https://docs.woocommerce.com/document/payment-gateway-api/
https://docs.woocommerce.com/document/settings-api/
https://rudrastyh.com/woocommerce/payment-gateway-plugin.html。
但是,就我而言,当我进入付款网关的设置页面时,从未调用过admin_options。
付款网关在付款方式列表中。在前端也可以选择付款方式。
在我添加了WC_Payment_Gateway的类中
public function admin_options() {
echo 'TEST';
die();
}
检查它是否被调用,但不是。诸如构造函数,init_form_fields之类的其他方法也会被调用,因此至少有一部分工作。
任何关于可能发生的事情或如何解决此问题的想法都非常受欢迎。
解决方法
$ this-> id包含一些大写字母。...似乎不允许...使它变为小写字母可以解决此问题。
我被#Vishal在这篇文章中的回答所触发:
WordPress Plugin WooCommerce,Custom Payment Gateway Settings Not Saving