You are here

public function UcAddressesUcZoneFieldHandler::mapValue in Ubercart Addresses 7

Overrides UcAddressesFieldHandler::mapValue().

The zone field has some extra mapping targets.

Overrides UcAddressesFieldHandler::mapValue

File

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

Class

UcAddressesUcZoneFieldHandler
Class for the Ubercart zone field.

Code

public function mapValue($value, $format = '') {
  switch ($format) {
    case 'zone_code':
    case 'zone_name':

      // Lookup zone data.
      $zone_id = db_select('uc_zones', 'uc_zones')
        ->condition($format, $value)
        ->fields('uc_zones', array(
        'zone_id',
      ))
        ->execute()
        ->fetchField();
      if ($zone_id) {
        $value = $zone_id;
      }
      break;
  }
  parent::mapValue($value, $format);
}