Okay, I've managed to finish it. Good timing because my girl wants me to help in the garden. This is basically what I changed:
<?php
/**
* Implementation of hook_user().
*/
function uc_addresses_user($op, &$edit, &$account, $category = null){
global $user;
switch ($op){
case 'view':
if (user_access('edit and view addresses') || $user->uid == $account->uid) {
$link = l('here', 'user/'. $account->uid .'/addresses');
$items = array();
$items['addresses'] = array('title' => t('Manage Addresses'),
'value' => 'Click ' . $link . ' to manage your addresses.',
'class' => 'member',
);
return array(t('Addresses') => $items);
}
else {
return NULL;
}
case 'register':
// get the address form
$form = uc_addresses_pane_address('new', $arg1, $arg2);
$form = array($form['contents']); // modify to what we need
$form[0]['#title'] = 'Address'; // rename the fieldset
return $form;
case 'insert':
$address = (object)$edit;
uc_addresses_add_address($address);
return;
case 'delete':
db_query("DELETE FROM {uc_addresses} WHERE uid = %d", $account->uid);
return;
}
}
/**
* Implementation of hook_form_alter().
*
* Here we're going to override the saved address options on the checkout form
*/
function uc_addresses_form_alter($form_id, &$form) {
global $user;
if ($form_id == 'uc_cart_checkout_form') {
$options = array('0' => t('Select one...'));
// grab the addresses saved from previous checkouts
if ($addresses = uc_get_addresses($user->uid, $type)) {
foreach ($addresses as $address) {
$options[drupal_to_js($address)] = $address['street1'];
}
}
// grab the addresses saved at registration or added in the user profile
if ($addresses = uc_addresses_get_address($user->uid, NULL, 0)) {
foreach ($addresses as $address) {
$address = (array)$address;
$options[drupal_to_js($address)] = $address['street1'];
}
}
// inject into form
$form['panes']['delivery']['delivery_address_select']['#options'] = $options;
$form['panes']['billing']['billing_address_select']['#options'] = $options;
}
}
?>I've uploaded the files so you guys can test/improve this. Look forward to seeing what you come up with.
| Attachment | Size |
|---|---|
| uc_addresses.tar.gz | 10.42 KB |



Joined: 08/28/2007