public function getData(Order $order)
{
$data = $this->getAddress($order)->toMap();
//merge data from multiple sources
$data = array_merge(ShopUserInfo::singleton()->getLocation(), $data, array($this->addresstype . "AddressID" => $order->{$this->addresstype . "AddressID"}));
//merge in default address if an address isn't available
$member = Member::currentUser();
if (!$order->{$this->addresstype . "AddressID"}) {
$data = array_merge(ShopUserInfo::singleton()->getLocation(), $member ? $member->{"Default" . $this->addresstype . "Address"}()->toMap() : array(), array($this->addresstype . "AddressID" => $order->{$this->addresstype . "AddressID"}));
}
unset($data['ID']);
unset($data['ClassName']);
unset($data['RecordClassName']);
//ensure country is restricted if there is only one allowed country
if ($country = SiteConfig::current_site_config()->getSingleCountry()) {
$data['Country'] = $country;
}
return $data;
}