woocommerce plugin add_action always return -1

Problem

add_action( 'woocommerce_api_wc_gateway_test', 'check_response');
function check_response() {
    echo 'test';
    return 'test';
}

when call https://loaclhost/index.php/wc-api/WC_Gateway_Test, always return httpCode: 200, response body: -1

Solution

add_action( 'woocommerce_api_wc_gateway_test', 'check_response');

function check_response() {
    echo '{"code": 200}';
    exit;
}

参考:https://github.com/woocommerce/woocommerce/issues/28830
参考:https://docs.woocommerce.com/document/payment-gateway-api/
参考:https://woocommerce.github.io/code-reference/files/woocommerce-includes-gateways-paypal-includes-class-wc-gateway-paypal-ipn-handler.html

上一篇 WordPress插件开发注意事项
下一篇 提升WooCommerce商店的安全性
目录
文章列表
1 腾讯企业邮箱配置图文教程
腾讯企业邮箱配置图文教程
2
React Native学习之Text组件
React Native学习之Text组件
3
高中数学基础:集合与函数
高中数学基础:集合与函数
4
React在安卓浏览器打开白屏问题
React在安卓浏览器打开白屏问题
5
ZooKeeper客户端 zkCli.sh 节点的增删改查
ZooKeeper客户端 zkCli.sh 节点的增删改查
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。