Skip to content

Commit

Permalink
Add address data for guest orders on order endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin-Magmodules committed Dec 5, 2024
1 parent de5c274 commit 188a3da
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Service/WebApi/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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;
Expand Down

0 comments on commit 188a3da

Please sign in to comment.