You are here

public function UcAddressesUcZoneFieldHandler::outputValue in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 handlers/ubercart.handlers.inc \UcAddressesUcZoneFieldHandler::outputValue()

Overrides UcAddressesFieldHandler::outputValue().

The zone field can be outputted in different formats.

Overrides UcAddressesFieldHandler::outputValue

File

handlers/ubercart.handlers.inc, line 218
Field handlers for Ubercart core address fields: first_name, last_name, company, etc.

Class

UcAddressesUcZoneFieldHandler
Class for the Ubercart zone field.

Code

public function outputValue($value = '', $format = '') {
  if ($value === '') {
    $value = $this
      ->getAddress()
      ->getField($this
      ->getFieldName());
  }

  // Get zone data.
  $result = db_select('uc_zones')
    ->condition('zone_id', $value)
    ->fields('uc_zones')
    ->execute();
  $row = $result
    ->fetch();
  if ($row) {
    $zone_data = array(
      'zone_code' => $row->zone_code,
      'zone_name' => $row->zone_name,
    );
  }
  else {
    $zone_data = array(
      'zone_code' => t('N/A'),
      'zone_name' => t('Unknown'),
    );
  }
  if (isset($zone_data[$format])) {
    return $zone_data[$format];
  }

  // If no format is specified, return zone name.
  return $zone_data['zone_name'];
}