You are here

function basic_cart_price_format in Basic cart 7.3

Same name and namespace in other branches
  1. 7.2 basic_cart.cart.inc \basic_cart_price_format()

Formats the input $price in the desired format.

Parameters

float $price: The price in the raw format.

Return value

$price The price in the custom format.

11 calls to basic_cart_price_format()
basic_cart_block_view in ./basic_cart.module
Implements hook_block_view().
basic_cart_cart_flat.tpl.php in ./basic_cart_cart_flat.tpl.php
Basic cart shopping cart html template
basic_cart_cart_render_block.tpl.php in ./basic_cart_cart_render_block.tpl.php
Basic cart shopping cart block
basic_cart_field_formatter_view in ./basic_cart.module
Implements hook_field_formatter_view().
basic_cart_handler_field_price::render in views/basic_cart_handler_field_price.inc
Overrides views_handler_field::render().

... See full list

1 string reference to 'basic_cart_price_format'
basic_cart_admin_content_type in ./basic_cart.admin.inc
Callback for the admin configuration page.

File

./basic_cart.cart.inc, line 235
Basic cart shopping cart implementation functions.

Code

function basic_cart_price_format($price) {
  $format = variable_get('basic_cart_price_format');
  $currency = check_plain(variable_get('basic_cart_currency'));
  $price = (double) $price;
  switch ($format) {
    case 0:
      $price = number_format($price, 2, ',', ' ') . ' ' . $currency;
      break;
    case 1:
      $price = number_format($price, 2, '.', ' ') . ' ' . $currency;
      break;
    case 2:
      $price = number_format($price, 2, '.', ',') . ' ' . $currency;
      break;
    case 3:
      $price = number_format($price, 2, ',', '.') . ' ' . $currency;
      break;
    case 4:
      $price = $currency . ' ' . number_format($price, 2, ',', ' ');
      break;
    case 5:
      $price = $currency . ' ' . number_format($price, 2, '.', ' ');
      break;
    case 6:
      $price = $currency . ' ' . number_format($price, 2, '.', ',');
      break;
    case 7:
      $price = $currency . ' ' . number_format($price, 2, ',', '.');
      break;
    default:
      $price = number_format($price, 2, ',', ' ') . ' ' . $currency;
      break;
  }
  return $price;
}