You are here

function uc_fulfillment_address_property_get in Ubercart 8.4

Entity metadata callback to get origin or destination address of an shipment.

1 string reference to 'uc_fulfillment_address_property_get'
uc_fulfillment_rules_data_info in shipping/uc_fulfillment/uc_fulfillment.rules.inc
Implements hook_rules_data_info().

File

shipping/uc_fulfillment/uc_fulfillment.rules.inc, line 162
Rules hooks for uc_fulfillment.module.

Code

function uc_fulfillment_address_property_get($shipment, array $options, $name, $entity_type) {
  switch ($name) {
    case 'origin':
      $type = 'o_';
      break;
    case 'destination':
      $type = 'd_';
      break;
    default:
      return NULL;
  }
  $address = new Address();
  foreach ($address as $field => $value) {
    $address->{$field} = $shipment->{$type . $field};
  }
  return $address;
}