Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include state code in address for ups #276

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading