You are here

function uc_length_format in Ubercart 5

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

Format a length value for display.

3 calls to uc_length_format()
theme_uc_product_dimensions in uc_product/uc_product.module
Format a product's length, width, and height.
uc_product_token_values in uc_product/uc_product.module
Provide product token values.
uc_shipping_package_view in shipping/uc_shipping/uc_shipping.module
Display the details of a package.

File

uc_store/uc_store.module, line 1930
Contains global Ubercart functions and store administration functionality.

Code

function uc_length_format($value, $unit = NULL) {
  $vars = array(
    '!value' => $value,
  );
  if (is_null($unit)) {
    $unit = variable_get('uc_length_unit', 'in');
  }
  $defaults = array(
    'in' => '!valuein.',
    'ft' => '!valueft.',
    'cm' => '!valuecm',
    'mm' => '!valuemm',
  );
  $pattern = variable_get('uc_length_format_' . $unit, $defaults[$unit]);
  if (strpos($pattern, '!value') === FALSE) {
    $pattern = $defaults[$unit];
  }
  $format = strtr($pattern, $vars);
  return $format;
}