wc_load_webhooks()WC 3.3.0

Load webhooks.

No Hooks.

Return

true|false.

Usage

wc_load_webhooks( $status, $limit );
$status(string)
Optional - status to filter results by. Must be a key in return value of @see wc_get_webhook_statuses(). @since 3.5.0.
Default: ''
$limit(null|int)
Limit number of webhooks loaded. @since 3.6.0.
Default: null

Changelog

Since 3.3.0 Introduced.

wc_load_webhooks() code WC 8.7.0

function wc_load_webhooks( $status = '', $limit = null ) {
	$data_store = WC_Data_Store::load( 'webhook' );
	$webhooks   = $data_store->get_webhooks_ids( $status );
	$loaded     = 0;

	foreach ( $webhooks as $webhook_id ) {
		if ( ! is_null( $limit ) && $loaded >= $limit ) {
			break;
		}

		$webhook = new WC_Webhook( $webhook_id );
		$webhook->enqueue();
		$loaded ++;
	}

	return 0 < $loaded;
}