Skip to content

Commit

Permalink
restore country code check
Browse files Browse the repository at this point in the history
  • Loading branch information
GytisZum committed Feb 29, 2024
1 parent 6dca1fb commit 0f7f5b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions src/Adapter/AddressAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,9 @@ private function getFormattedZipCode(Country $country, $postCode)

$postCode = preg_replace("/[^a-zA-Z0-9]+/", "", $postCode);
// If C doesn't exist in zip code format - don't modify the zip code
//todo this check prevents from saving zip code to numeric not sure why c has to be checked
// if (false === $countryCodePosition) {
// return $postCode;
// }
if (false === $countryCodePosition) {
return $postCode;
}

$countryCodeLength = Tools::strlen($country->iso_code);
$countryCode = Tools::substr($postCode, $countryCodePosition, $countryCodeLength);
Expand Down
5 changes: 2 additions & 3 deletions src/Repository/ZoneRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
use Country;
use DbQuery;
use Invertus\dpdBaltics\Adapter\AddressAdapter;
use Invertus\dpdBaltics\Validate\Zone\ZoneRangeValidate;
use PrestaShopDatabaseException;

class ZoneRepository extends AbstractEntityRepository
Expand Down Expand Up @@ -102,9 +103,7 @@ public function addProductZonesFromArray(array $zones)
public function findZoneInRangeByAddress(Address $address)
{
$idCountry = $address->id_country ?: (int)\Configuration::get('PS_COUNTRY_DEFAULT');
$addressAdapter = new AddressAdapter();

$zipCode = $addressAdapter->getZipCodeByCountry($idCountry, $address->postcode);
$zipCode = ZoneRangeValidate::getNumericZipCode($address->postcode, $idCountry);

$query = new DbQuery();
$query->select('dz.id_dpd_zone');
Expand Down

0 comments on commit 0f7f5b7

Please sign in to comment.