function bat_options_field_formatter_view in Booking and Availability Management Tools for Drupal 7
Implements hook_field_formatter_view().
File
- modules/
bat_options/ bat_options.module, line 170
Code
function bat_options_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
switch ($display['type']) {
case 'bat_options_default':
foreach ($items as $delta => $item) {
$element[$delta] = array(
'#markup' => "{$item['quantity']} x {$item['name']}",
);
}
break;
case 'bat_options_price':
$currency_setting = commerce_currency_load(commerce_default_currency());
$currency_symbol = $currency_setting['symbol'];
foreach ($items as $delta => $item) {
$price = t('@currency_symbol@amount', array(
'@currency_symbol' => $currency_symbol,
'@amount' => number_format($item['value'], 2, '.', ''),
));
if ($item['value'] > 0) {
$element[$delta] = array(
'#markup' => "{$item['quantity']} x {$item['name']} - {$price}",
);
}
else {
$element[$delta] = array(
'#markup' => "{$item['quantity']} x {$item['name']}",
);
}
}
break;
case 'bat_options_admin':
foreach ($items as $delta => $item) {
$element[$delta] = array(
'#markup' => "{$item['quantity']} x {$item['name']} - {$item['operation']} {$item['value']}",
);
}
break;
}
return $element;
}