From 188a3da89d29395c4be9cd18fd3115b5576c9fca Mon Sep 17 00:00:00 2001 From: Marvin Besselsen Date: Thu, 5 Dec 2024 11:15:17 +0100 Subject: [PATCH] Add address data for guest orders on order endpoint --- Service/WebApi/Order.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Service/WebApi/Order.php b/Service/WebApi/Order.php index 567c5e3..0dbdfa4 100755 --- a/Service/WebApi/Order.php +++ b/Service/WebApi/Order.php @@ -136,7 +136,7 @@ private function getCollection( * * @return array|null */ - private function getProfileData($order): ?array + private function getProfileData(OrderModel $order): ?array { try { if ($order->getCustomerId()) { @@ -146,13 +146,24 @@ private function getProfileData($order): ?array 'email' => $customer->getEmail() ]; } else { - return [ + $data = [ 'id' => null, 'customer_firstname' => $order->getCustomerFirstname(), 'customer_middlename' => $order->getCustomerMiddlename(), 'customer_lastname' => $order->getCustomerLastname(), 'email' => $order->getCustomerEmail() ]; + if ($shipAddress = $order->getShippingAddress()) { + $data['region_id'] = $shipAddress->getRegionId(); + $data['region'] = $shipAddress->getRegion(); + $data['postcode'] = $shipAddress->getPostcode(); + $data['street'] = $shipAddress->getStreet(); + $data['city'] = $shipAddress->getCity(); + $data['telephone'] = $shipAddress->getTelephone(); + $data['country_id'] = $shipAddress->getCountryId(); + $data['company'] = $shipAddress->getCompany(); + } + return $data; } } catch (\Exception $exception) { return null;