You are here

function uc_store_format_price_field_value in Ubercart 7.3

Same name and namespace in other branches
  1. 6.2 uc_store/uc_store.module \uc_store_format_price_field_value()

Displays prices in forms with a minimum number of decimal places.

Parameters

$price: The price to display as the #default_value in a form field.

1 call to uc_store_format_price_field_value()
form_type_uc_price_value in uc_store/uc_store.module
Helper function to determine the value for a uc_price form element.

File

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

Code

function uc_store_format_price_field_value($price) {
  $exact = rtrim(number_format($price, 6, '.', ''), '0');
  $round = number_format($price, variable_get('uc_currency_prec', 2), '.', '');
  if ($exact == rtrim($round, '0')) {
    return $round;
  }
  else {
    return $exact;
  }
}