From 3049ff2f28d6c8891a7bee013de894eb6ef56cfd Mon Sep 17 00:00:00 2001 From: Joeri van Veen Date: Tue, 8 Oct 2024 15:09:30 +0200 Subject: [PATCH 1/2] fix: include state code in address for ups --- src/Pdk/Base/Adapter/PsAddressAdapter.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Pdk/Base/Adapter/PsAddressAdapter.php b/src/Pdk/Base/Adapter/PsAddressAdapter.php index 804cc934..77c4c0c7 100644 --- a/src/Pdk/Base/Adapter/PsAddressAdapter.php +++ b/src/Pdk/Base/Adapter/PsAddressAdapter.php @@ -66,8 +66,11 @@ 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, @@ -75,10 +78,11 @@ private function createFromAddress(Address $address): array '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, + ] : []); } /** From 40f41dff3a1b5ebb7c38aaad337c65bde9342814 Mon Sep 17 00:00:00 2001 From: Joeri van Veen Date: Tue, 8 Oct 2024 15:26:14 +0200 Subject: [PATCH 2/2] fix: include state code in address for ups --- src/Pdk/Base/Adapter/PsAddressAdapter.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Pdk/Base/Adapter/PsAddressAdapter.php b/src/Pdk/Base/Adapter/PsAddressAdapter.php index 77c4c0c7..339e6b73 100644 --- a/src/Pdk/Base/Adapter/PsAddressAdapter.php +++ b/src/Pdk/Base/Adapter/PsAddressAdapter.php @@ -67,8 +67,7 @@ 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); + ? null : new State($address->id_state); return array_merge([ 'cc' => $country->iso_code,