You are here

function uc_weight_format in Ubercart 5

Same name and namespace in other branches
  1. 8.4 uc_store/uc_store.module \uc_weight_format()
  2. 6.2 uc_store/uc_store.module \uc_weight_format()
  3. 7.3 uc_store/uc_store.module \uc_weight_format()

Format a weight value for display.

4 calls to uc_weight_format()
theme_uc_product_weight in uc_product/uc_product.module
Format a product's weight.
uc_product_token_values in uc_product/uc_product.module
Provide product token values.
uc_store_store_settings_overview in uc_store/uc_store.module
Display the store settings overview page.
uc_views_handler_weight in uc_product/uc_product.module
Return a formatted weight value to display in the View.
1 string reference to 'uc_weight_format'
uc_store_uninstall in uc_store/uc_store.install

File

uc_store/uc_store.module, line 1890
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;
}