Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_action always return -1 #28830

Closed
iyezhou opened this issue Jan 17, 2021 · 1 comment
Closed

add_action always return -1 #28830

iyezhou opened this issue Jan 17, 2021 · 1 comment

Comments

@iyezhou
Copy link

iyezhou commented Jan 17, 2021

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

@juliaamosova juliaamosova added the needs: developer feedback Issues that need feedback from one of the WooCommerce Core developers. label Feb 6, 2021
@barryhughes
Copy link
Member

Hi @iyezhou,

When using the woocommerce_api_* dynamic hook in this way, the status code and any data you wish to return is something you need to take care of yourself, for instance by adding something like status_header( 400 ); within your callback.

We don't provide support here on GitHub, but if you still think there is a problem or bug then it would be great to have a little more insight into what you are trying to do, and what you expect (bear in mind, too, that this approach mostly exists for the benefit of payment gateways).

@barryhughes barryhughes removed the needs: developer feedback Issues that need feedback from one of the WooCommerce Core developers. label Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants