Skip to content

Commit

Permalink
fix: include state code in address for ups (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
joerivanveen authored Oct 10, 2024
1 parent ea026d1 commit e89a2f5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Pdk/Base/Adapter/PsAddressAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,22 @@ public function fromOrder($order, string $addressType = self::ADDRESS_TYPE_SHIPP
private function createFromAddress(Address $address): array
{
$country = new Country($address->id_country);
$state = $country->iso_code === Platform::get('localCountry')
? null : new State($address->id_state);

return [
return array_merge([
'cc' => $country->iso_code,
'city' => $address->city,
'address1' => $address->address1,
'address2' => $address->address2,
'postalCode' => $address->postcode,
'person' => trim(sprintf('%s %s', $address->firstname, $address->lastname)),
'phone' => $address->phone,
'region' => $country->iso_code === Platform::get('localCountry')
? null
: (new State($address->id_state))->name,
];
],
$state ? [
'region' => $state->name,
'state' => $state->iso_code,
] : []);
}

/**
Expand Down

0 comments on commit e89a2f5

Please sign in to comment.