You are here

function uc_shipping_address_property_get in Ubercart 7.3

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

1 string reference to 'uc_shipping_address_property_get'
uc_shipping_rules_data_info in shipping/uc_shipping/uc_shipping.rules.inc
Implements hook_rules_data_info().

File

shipping/uc_shipping/uc_shipping.rules.inc, line 160
Rules hooks for uc_shipping.module.

Code

function uc_shipping_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 UcAddress();
  foreach ($address as $field => $value) {
    $address->{$field} = $shipment->{$type . $field};
  }
  return $address;
}