You are here

function uc_addresses_uc_checkout_complete in Ubercart Addresses 6

Same name and namespace in other branches
  1. 6.2 uc_addresses.module \uc_addresses_uc_checkout_complete()
  2. 7 uc_addresses.module \uc_addresses_uc_checkout_complete()

Use hook_uc_checkout_complete to catch any new addresses.

Parameters

$order The order.:

$user The user.:

File

./uc_addresses.module, line 633

Code

function uc_addresses_uc_checkout_complete($order, $user) {
  $address = new stdClass();

  // Add the billing address first. If the user has no addresses,
  // this is the one that will become the default address
  if (variable_get('uc_pane_billing_enabled', TRUE)) {
    $address->address_name = '';
    $address->uid = $order->uid;
    $address->first_name = $order->billing_first_name;
    $address->last_name = $order->billing_last_name;
    $address->company = $order->billing_company;
    $address->street1 = $order->billing_street1;
    $address->street2 = $order->billing_street2;
    $address->city = $order->billing_city;
    $address->zone = $order->billing_zone;
    $address->postal_code = $order->billing_postal_code;
    $address->country = $order->billing_country;
    $address->phone = $order->billing_phone;
    $address->is_default = 0;
    _uc_addresses_db_add_address($address, TRUE);
  }
  if (uc_order_is_shippable($order)) {
    $address->address_name = '';
    $address->uid = $order->uid;
    $address->first_name = $order->delivery_first_name;
    $address->last_name = $order->delivery_last_name;
    $address->company = $order->delivery_company;
    $address->street1 = $order->delivery_street1;
    $address->street2 = $order->delivery_street2;
    $address->city = $order->delivery_city;
    $address->zone = $order->delivery_zone;
    $address->postal_code = $order->delivery_postal_code;
    $address->country = $order->delivery_country;
    $address->phone = $order->delivery_phone;
    $address->is_default = 0;
    _uc_addresses_db_add_address($address, TRUE);
  }
}