function hook_uc_addresses_format_address_alter in Ubercart Addresses 6.2
Same name and namespace in other branches
- 7 uc_addresses.api.php \hook_uc_addresses_format_address_alter()
This hook allows you to alter an address format before it's being processed.
This is useful if you want to display the address in a different way under some kind of circumstances. For example, you may want to exclude the display of first name and last name when you display an address in your own context.
Warning: do not convert the address object to a string as that will result into an infinite loop.
Parameters
string $format: The unprocessed address format (tokens still need to be replaced).
UcAddressesAddress $address: The address object for which a format is processed.
string $context: The context in which the address will be displayed.
Return value
void
1 invocation of hook_uc_addresses_format_address_alter()
- uc_addresses_format_address in ./
uc_addresses.module - Format an address by using tokens.
File
- ./
uc_addresses.api.php, line 505 - 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_format_address_alter(&$format, $address, $context) {
// Example: remove the line that contains the last name completely when the
// context is "order_view".
if ($context == "order_view") {
$lines = explode("\n", $format);
foreach ($lines as $line_number => $line) {
if (strpos($line, '[uc_addresses_last_name]') !== FALSE) {
unset($lines[$line_number]);
}
}
$format = implode("\n", $lines);
}
}