function hook_uc_addresses_address_presave in Ubercart Addresses 6.2
Same name and namespace in other branches
- 7 uc_addresses.api.php \hook_uc_addresses_address_presave()
This hook allows you alter the address just before it's saved.
Parameters
UcAddressesAddress $address: The address object.
Return value
void
1 invocation of hook_uc_addresses_address_presave()
- UcAddressesAddress::save in class/
UcAddressesAddress.class.php - Saves address if address is marked as 'dirty'.
File
- ./
uc_addresses.api.php, line 203 - These hooks are invoked by the Ubercart Addresses module. @todo more documentation needed for hook_uc_addresses_field_handlers(). @todo Document the rest of the API.
Code
function hook_uc_addresses_address_presave($address) {
// Example: set a nickname for this address if there is none.
if ($address
->getName() == '') {
$nickname = 'my address name';
if (!$address
->setName($nickname)) {
// Try an other name if this nickname is already used.
$numb = 2;
$other_nickname = $nickname . ' ' . $numb++;
while (!$address
->setName($other_nickname)) {
$other_nickname = $nickname . ' ' . $numb++;
}
}
}
}