WC_Admin_Webhooks::get_topic_data()public staticWC 1.0

Get the webhook topic data.

{} It's a method of the class: WC_Admin_Webhooks{}

No Hooks.

Return

Array.

Usage

$result = WC_Admin_Webhooks::get_topic_data( $webhook );
$webhook(WC_Webhook) (required)
Webhook instance.

Code of WC_Admin_Webhooks::get_topic_data() WC 6.7.0

public static function get_topic_data( $webhook ) {
	$topic    = $webhook->get_topic();
	$event    = '';
	$resource = '';

	if ( $topic ) {
		list( $resource, $event ) = explode( '.', $topic );

		if ( 'action' === $resource ) {
			$topic = 'action';
		} elseif ( ! in_array( $resource, array( 'coupon', 'customer', 'order', 'product' ), true ) ) {
			$topic = 'custom';
		}
	}

	return array(
		'topic'    => $topic,
		'event'    => $event,
		'resource' => $resource,
	);
}