You are here

function uc_currency_format in Ubercart 5

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

Format an amount for display with the store's currency settings.

77 calls to uc_currency_format()
op_products_customer_table in uc_order/uc_order_order_pane.inc
op_products_view_table in uc_order/uc_order_order_pane.inc
Build the order view products table.
test_gateway_charge in payment/uc_payment/test_gateway.module
theme_cart_review_table in uc_cart/uc_cart_checkout_pane.inc
theme_uc_cart_block_content in uc_cart/uc_cart.module
Theme the shopping cart block content.

... See full list

File

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

Code

function uc_currency_format($value, $sign = TRUE, $thou = TRUE, $dec = NULL) {
  if ($value === NULL) {
    return NULL;
  }
  if (variable_get('uc_currency_prec', 2) > 0) {
    if (abs($value) < '.' . str_repeat('0', variable_get('uc_currency_prec', 2) - 1) . '1') {
      $value = 0;
    }
  }
  $format = '';
  if ($value < 0) {
    $value = abs($value);
    $format = '-';
  }
  if ($sign && !variable_get('uc_sign_after_amount', FALSE)) {
    $format .= variable_get('uc_currency_sign', '$');
  }
  $format .= number_format($value, variable_get('uc_currency_prec', 2), !is_null($dec) ? $dec : variable_get('uc_currency_dec', '.'), $thou ? variable_get('uc_currency_thou', ',') : '');
  if ($sign && variable_get('uc_sign_after_amount', FALSE)) {
    $format .= variable_get('uc_currency_sign', '$');
  }
  return $format;
}