public function setData(Order $order, array $data)
{
$existingID = !empty($data[$this->addresstype . "AddressID"]) ? (int) $data[$this->addresstype . "AddressID"] : 0;
if ($existingID > 0) {
$order->{$this->addresstype . "AddressID"} = $existingID;
$order->write();
$order->extend('onSet' . $this->addresstype . 'Address', $address);
} else {
parent::setData($order, $data);
}
}