Hello everyone,
I just recently discovered Ubercart and have been very impressed. I am working on a site that integrates with a legacy member database that stores all kinds of information about each member and associates it with their Drupal accounts, and I would like to be able to pre-populate the shipping address fields on the checkout screen using this data, but I'm having some trouble doing so.
Here's what I've got:
function myorg_form_alter($form_id, &$form) {
if($form_id == 'uc_cart_checkout_form') {
global $user;
$user = user_load(array('uid'=>$user->uid)); // Load user data from legacy system
if(!$user->myorg_id)
return;
if($user->myorg_type == 'member') {
$dpane = $form['panes']['delivery'];
$dpane['delivery_first_name']['#default_value'] = $user->first_name;
$dpane['delivery_last_name']['#default_value'] = $user->last_name;
$dpane['delivery_street1']['#default_value'] = $user->street_address;
$dpane['delivery_city']['#default_value'] = $user->city;
}
}
}However, it's not working, the default values are never set. I can print them out as variables later in the function, and they are there correctly, but they somehow don't make it to the final form display.
Does anyone know why?
Thanks,
Ben


)




I am currently needing to do the same thing which is auto populate the billing or shipping information with the information that was provided from the user in their user profile. So lets dig in.