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

版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/25/woocommerce-plugin-add_action-always-return-1/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
打赏
海报
woocommerce plugin add_action always return -1
Problem add_action( 'woocommerce_api_wc_gateway_test', 'check_response'); function check_response() { echo 'test';……
<<上一篇
下一篇>>
文章目录
关闭
目 录