Send woocommerce order data to and external url of Drupal
Check WooCommerce Webhook Setup
Go to WooCommerce → Settings → Advanced → Webhooks.
Make sure:
Status = Active
Topic = e.g.,
Order created
/Order updated
/Order paid
(whichever you want).Delivery URL =
https://examplewebsite/customurl
Secret = You can leave blank unless you want HMAC verification.
You can test webhook delivery by creating a new order and checking WooCommerce → Status → Logs under Webhook delivery logs.
Check Your Drupal Endpoint
WooCommerce sends a POST request with JSON body.
You need to make sure Drupal is accepting POST JSON.
A minimal Drupal controller example:
namespace Drupal\mymodule\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\JsonResponse; class WebhookController { public function receive(Request $request) { // Get raw body $data = json_decode($request->getContent(), TRUE); if (empty($data)) { return new JsonResponse(['status' => 'error', 'message' => 'No data received'], 400); } // Log or process order data \Drupal::logger('mymodule')->notice('@data', ['@data' => print_r($data, TRUE)]); return new JsonResponse(['status' => 'success', 'message' => 'Data received']); } }