function uc_addresses_new_address_from_order in Ubercart Addresses 7
Creates a new address from order data.
Parameters
object $order: An Ubercart order object.
string $order_address_type: The type of address to create: delivery or billing.
Return value
UcAddressesAddress An instance of UcAddresses, filled with values from order object.
2 calls to uc_addresses_new_address_from_order()
- uc_addresses_order_attach_addresses in ./
uc_addresses.module - Attaches UcAddressesAddress instances to the order.
- uc_addresses_uc_order in ./
uc_addresses.module - Implements hook_uc_order().
File
- ./
uc_addresses.module, line 1297 - Adds user profile address support to Ubercart.
Code
function uc_addresses_new_address_from_order($order, $order_address_type) {
$address = UcAddressesAddressBook::get($order->uid)
->addAddress();
// Loop through all address field definitions and set those that exists for the order.
$fields_data = uc_addresses_get_address_fields();
foreach ($fields_data as $fieldname => $fielddata) {
$order_field_name = $order_address_type . '_' . $fieldname;
if (isset($order->{$order_field_name})) {
$address
->setField($fieldname, $order->{$order_field_name});
}
}
return $address;
}