5 replies [Last post]
dolittle's picture
Offline
Joined: 01/30/2008
Juice: 111
Was this information Helpful?

Hi,

Is it possible that the checkout form will populate automaticaly the top saved address?

Customers that'll buy the same product every week will have to make to many clicks...

Thanks

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15450
Re: Default billing address on checkout form

You can do this with a custom module using hook_form_alter() or a bit of JS on the checkout page. Altering the form is probably the easiest way to go.

dolittle's picture
Offline
Joined: 01/30/2008
Juice: 111
Re: Re: Default billing address on checkout form

I hoped it could be the default because I guess everybody will want it.

Thanks

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15450
Re: Re: Re: Default billing address on checkout form

Well, as is it's really only one select box for return customers, so I don't think it's asking too much of them. Eye-wink

mandclu's picture
Offline
Bug Finder
Joined: 11/19/2007
Juice: 78
Re: Re: Re: Re: Default billing address on checkout form

I think particularly for retail customers, it makes sense to have the checkbox selected by default. Doesn't it makes sense to add a setting so that individual stores can easily set a default?

robdinardo's picture
Offline
Joined: 02/01/2009
Juice: 27
default select option from profile field on js select

How would I set default of a custom select list? I created a table of branch addresses that I use to populate the select list. I also pull the users' branch from LDAP (profile field). How do I select it as default? The value of the tag contains data of all the fields. Thanks for your help.

<?php
function uc_approval_select_branch($uid, $type = 'billing', $onchange = '', $title = NULL, $icon_suffix = FALSE) {

    global

$user;   
   
$user_info = user_load(array('uid'=>$user->uid));
   
     
$branches = uc_approval_get_branches($uid, $type);

if(!

is_array($branches) || count($branches) == 0) { return NULL; }

 

$options = array('0' => t('Select one...'));
  foreach (
$branches as $branch) {
   
$options[drupal_to_js($branch)] = check_plain($branch['name']);
   
// check if the branch matches
   
if ($branch['name'] == $user_info->profile_branch) {
       
$default = $options[drupal_to_js($branch)];  // set the $default
   
}
  }

 

$select = array(
   
'#type' => 'select',
   
'#title' => is_null($title) ? t('Branches') : $title,
   
'#options' => $options,
   
'#attributes' => array('onchange' => $onchange),
   
'#suffix' => $icon_suffix ? uc_store_get_icon('file:address_book', FALSE, 'address-book-icon') : NULL,
     
'#weight' => -5,
   
'#default_value' => $default// apply the default
 
);

  return

$select;
}
?>

By the way, I tried

<?php
$form
['panes']['delivery']['delivery_branch_select']['#default_value'] = $user_info->profile_branch;
?>

but it did not work.