You are here

function uc_addresses_order_attach_addresses in Ubercart Addresses 7

Attaches UcAddressesAddress instances to the order.

2 calls to uc_addresses_order_attach_addresses()
uc_addresses_uc_order in ./uc_addresses.module
Implements hook_uc_order().
uc_addresses_uc_order_address_property_get in ./uc_addresses.module
Entity API getter callback for an address attached to the order.

File

./uc_addresses.module, line 1262
Adds user profile address support to Ubercart.

Code

function uc_addresses_order_attach_addresses($order) {
  $order->uc_addresses = array();
  foreach (uc_addresses_order_address_types() as $order_address_type) {
    $address_type = $order_address_type;
    if ($order_address_type == 'delivery') {
      $address_type = 'shipping';
    }

    // Check session first for temporary saved addresses.
    if (isset($_SESSION['uc_addresses_order'][$order->order_id][$address_type])) {
      $address = unserialize($_SESSION['uc_addresses_order'][$order->order_id][$address_type]);
    }
    else {

      // Construct new address.
      $address = uc_addresses_new_address_from_order($order, $order_address_type);
    }
    $address->address_type = $address_type;
    $order->uc_addresses[$address_type] = $address;
  }

  // Allow other modules to react on this.
  module_invoke_all('uc_addresses_order_load', $order);
}