uc_weight_format
Drupal 7 uc_weight_format($value, $unit = NULL)
Formats a weight value for display.
Parameters
$value: Numerical weight value.
$unit: Weight unit. One of 'lb', 'oz', 'kg', or 'g', or NULL to use store default weight units.
Return value
String containing formattted weight, including weight units.
4 calls to uc_weight_format()
File
- sites/
all/ modules/ ubercart/ uc_store/ uc_store.module, line 925 - Contains global Ubercart functions and store administration functionality.
Code
function uc_weight_format($value, $unit = NULL) {
$vars = array('!value' => $value);
if (is_null($unit)) {
$unit = variable_get('uc_weight_unit', 'lb');
}
$defaults = array(
'lb' => '!value lb.',
'oz' => '!value oz.',
'kg' => '!valuekg',
'g' => '!valueg',
);
$pattern = variable_get('uc_weight_format_' . $unit, $defaults[$unit]);
if (strpos($pattern, '!value') === FALSE) {
$pattern = $defaults[$unit];
}
$format = strtr($pattern, $vars);
return $format;
}

