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 some international Shipping States #13

Open
wants to merge 5 commits into
base: 8.x-1.x
Choose a base branch
from
Open
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
104 changes: 104 additions & 0 deletions src/FedExAddressResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,108 @@ public static function addressResolveAU(AddressInterface $address) {
return $party;
}

/**
* Resolve Addresses in Hong Kong.
*
* @param \Drupal\address\AddressInterface $address
* The address to resolve.
*
* @return \NicholasCreativeMedia\FedExPHP\Structs\Party
* A Fedex Compatible party.
*/
public static function addressResolveHK(AddressInterface $address) {

$party = new Party();

$party->setAddress(new Address(
array_filter([$address->getAddressLine1(), $address->getAddressLine2()]),
$address->getAdministrativeArea() . ', ' . $address->getLocality(),
NULL,
$address->getPostalCode(),
NULL,
$address->getCountryCode(),
NULL,
FALSE
));

return $party;
}

public static function addressResolveBB(AddressInterface $address) {

$party = new Party();

$party->setAddress(new Address(
array_filter([$address->getAddressLine1(), $address->getAddressLine2()]),
$address->getAdministrativeArea(),
NULL,
$address->getPostalCode(),
NULL,
$address->getCountryCode(),
NULL,
FALSE
));

return $party;
}

/**
* Resolve Addresses in Ireland.
*
* @param \Drupal\address\AddressInterface $address
* The address to resolve.
*
* @return \NicholasCreativeMedia\FedExPHP\Structs\Party
* A Fedex Compatible party.
*/
public static function addressResolveIE(AddressInterface $address) {

$provinces = [
'Co. Carlow' => 'N0',
'Co. Cavan' => 'N1',
'Co. Clare' => 'N2',
'Co. Cork' => ' N3',
'Co. Donegal' => 'N4',
'Co. Dublin' => 'N5',
'Co. Galway' => 'N6',
'Co. Kerry' => 'N7',
'Co. Kildare' => 'N8',
'Co. Kilkenny' => 'N9',
'Co. Laois' => 'NA',
'Co. Leitrim' => 'NG',
'Co. Limerick' => 'NI',
'Co. Longford' => 'NK',
'Co. Louth' => 'NL',
'Co. Mayo' => 'NM',
'Co. Meath' => 'NO',
'Co. Monaghan' => 'NP',
'Co. Offaly' => 'NQ',
'Co. Roscommon' => 'NR',
'Co. Sligo' => 'NW',
'Co. Tipperary' => 'NX',
'Co. Tipperary' => 'NY',
'Co. Waterford' => 'NZ',
'Co. Westmeath' => '10',
'Co. Wexford' => '11',
'Co. Wicklow' => '12',

];


$party = new Party();

$party->setAddress(new Address(
array_filter([$address->getAddressLine1(), $address->getAddressLine2()]),
$address->getAdministrativeArea(),
$provinces[$address->getAdministrativeArea()],
$address->getPostalCode(),
NULL,
$address->getCountryCode(),
NULL,
FALSE
));

return $party;
}

}