You are here

public function RoomsUnitFieldHandlerBasePrice::getFieldInfo in Booking and Availability Management API 7

Overrides RoomsUnitFieldHandlerInterface::getFieldInfo

File

plugins/rooms_unit_field_handler/field_handler_base_price.inc, line 16

Class

RoomsUnitFieldHandlerBasePrice

Code

public function getFieldInfo() {
  $price_fields = array();
  $rooms_unit_type = rooms_unit_type_load($this->unit->type);
  $base_price_field = NULL;
  if (isset($rooms_unit_type->data['pricing_field'])) {
    $base_price_field = $rooms_unit_type->data['pricing_field'];
  }
  $fields = field_info_instances('rooms_unit', $this->unit->type);
  foreach ($fields as $field) {
    $field_info = field_info_field($field['field_name']);
    if ($field_info['type'] == 'commerce_price') {
      $field_array = $this->unit->{$field['field_name']};
      if ($field['field_name'] == $base_price_field) {
        if (isset($field_array[LANGUAGE_NONE][0]['amount'])) {
          $price_fields[$field['field_name']] = array(
            'amount' => $field_array[LANGUAGE_NONE][0]['amount'],
            'currency_code' => $field_array[LANGUAGE_NONE][0]['currency_code'],
          );
        }
        else {
          $price_fields[$field['field_name']] = array();
        }
      }
    }
  }
  return $price_fields;
}