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全栈技术分享
文章版权归作者所有,未经允许请勿转载。
共有 0 条评论