WC_Webhook::failed_delivery()privateWC 2.2.0

Track consecutive delivery failures and automatically disable the webhook. if more than 5 consecutive failures occur. A failure is defined as a. non-2xx response.

Method of the class: WC_Webhook{}

Return

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->failed_delivery();

Changelog

Since 2.2.0 Introduced.

WC_Webhook::failed_delivery() code WC 8.7.0

private function failed_delivery() {
	$failures = $this->get_failure_count();

	if ( $failures > apply_filters( 'woocommerce_max_webhook_delivery_failures', 5 ) ) {
		$this->set_status( 'disabled' );

		do_action( 'woocommerce_webhook_disabled_due_delivery_failures', $this->get_id() );
	} else {
		$this->set_failure_count( ++$failures );
	}

	$this->save();
}