How to Modify WooCommerce Webhook with Custom Data

Learn how to easily add custom fields to WooCommerce webhooks for enhanced integration and tailored event notifications.

I was looking into adding my own custom data to WooCommerce Webhook and I found this way to easily integrate it within the functions.php file.

So the fastest way would be to apply a filter to the payload

add_filter( 'woocommerce_webhook_payload', 'my_woocommerce_webhook_payload', 10, 4 );
function my_woocommerce_webhook_payload( $payload, $resource, $resource_id, $id ) {
	if ( $resource !== 'order' ) {
		return $payload;
	}

	// Our logic will be here

	return $payload;
}

This is being applied to the order load so if it is not an order it will just return the payload, but if it is not we can inject our code where it says our logic.

Full Article: https://kayart.dev/woocommerce-webhooks-custom-fields/