8

I'm developing an order management system that hooks into WooCommerce but the Webhook behaves irregularly. The Webhook gets disabled on its own.

I've investigated with the users - none of them have privileges. The administrator hasn't touched this section and hasn't updated any of the plugins.

Are there any reasons this would happen? Maybe returning http errors from my side?

WordPress: 4.4.1
WooCommerce: 2.3.8
5
  • Why am I downvoted, did I do something wrong?
    – Alex Seif
    Jan 18, 2016 at 13:51
  • 2
    Not my downvote, but I see no information to work off of. There is zero code, there isn't even a name of the webhook in question, which makes it impossible to search around for similar troubles people may have testified about online. Jan 18, 2016 at 16:10
  • 1
    Thank you for the help so far, but I'm confused. Why would there be any code, it's a WooCommerce webhook, it's configured for "order.created", has a secret and is activated. Then suddenly it's disabled.
    – Alex Seif
    Jan 18, 2016 at 20:49
  • How did you configure it? What is the hook's name? Jan 20, 2016 at 2:07
  • I really don't understand the relevance of this question. The name is something you choose. Anyhow the Name: ERP Webhook Status: Active Topic: order.created
    – Alex Seif
    Jan 20, 2016 at 17:27

3 Answers 3

9

If you don't want to fix this every time WooCommerce updates, just create a filter in your child-theme:

function overrule_webhook_disable_limit( $number ) {
    return 999999999999; //very high number hopefully you'll never reach.
}
add_filter( 'woocommerce_max_webhook_delivery_failures', 'overrule_webhook_disable_limit' );
6

Apparently a WooCommerce Webhook will automatically disable due to delivery failure. https://docs.woothemes.com/document/webhooks/#section-3

“Disabled” (does not deliver due delivery failures).

2

Automatically disabled due to delivery failures (as mentioned above).

Because I'm depending on them a lot and never wants them disabled (no matter what), you can change function called failed_delivery() in this file: plugins/woocommerce/includes/class-wc-webhook.php to this:

private function failed_delivery() {

    $failures = $this->get_failure_count();

    if ( $failures > apply_filters( 'woocommerce_max_webhook_delivery_failures', 5 ) ) {

        //$this->update_status( 'disabled' );
        update_post_meta( $this->id, '_failure_count', ++$failures );

    } else {

        update_post_meta( $this->id, '_failure_count', ++$failures );
    }
}

and they will never be automagically disabled again.

2
  • 3
    Don't EVER edit third party plugins files and even less tell people to do that.
    – Casper
    Jul 12, 2019 at 17:45
  • I have to disagree. What if you want to fix vulnerability yourself which author can't fix on time? Or customise something? Obviously you EDIT third party plugin files. Just know what you're doing and keep it up to date with your changes. Better safe than sorry. Dec 17, 2019 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.