From 7ab1be2cd18538eab49745d971837a26432a4d35 Mon Sep 17 00:00:00 2001 From: Mario Guimaraes Date: Fri, 2 Jan 2026 11:46:51 -0500 Subject: [PATCH] Fix 'Attempt to read property metadata on null' in Webhooks controller This commit adds safe property access (null coalescing) for webhook payload data, specifically preventing errors when 'data->order' is missing in the webhook body. --- src/Controller/Webhooks.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Controller/Webhooks.php b/src/Controller/Webhooks.php index 20daf75c..dd141c47 100644 --- a/src/Controller/Webhooks.php +++ b/src/Controller/Webhooks.php @@ -61,7 +61,10 @@ public function handle_requests() $this->config->log()->info('Webhook Received: empty body!'); return; } - if (!$this->orderByWoocommerce($body->data->code, $body->data->order->metadata, $body->id) ) { + $code = $body->data->code ?? null; + $metadata = $body->data->order->metadata ?? null; + + if (!$this->orderByWoocommerce($code, $metadata, $body->id) ) { return; }