I'm somewhat new to Drupal and Ubercart so be gentle if this is a dumb question. I'm trying to add Ubercart to an existing Drupal/CiviCRM install. I've been asked to populate the address information during checkout with the users current contact information. I've been able to retrieve the information from CiviCRM using "civicrm_contact_get()" and I've been able to populate most of the fields...however when I get to the country and state fields, I'm not sure how to go about it.
This is what I have so far:
function mytest_form_alter($form_id, &$form) {
global $user;
require_once 'api/v2/Contact.php';
if ($form_id == 'uc_cart_checkout_form') {
if (isset($_SERVER['HTTP_REFERER'])) {
if (strpos($_SERVER['HTTP_REFERER'],'q=cart')!==false &&
strpos($_SERVER['HTTP_REFERER'],'q=cart/')==false){
if ($user->uid > 0){
$params = array( 'contact_id' => $user->uid);
$retrieved = civicrm_contact_get( $params );
$form['panes']['delivery']['delivery_first_name']['#value'] = $retrieved['first_name'];
$form['panes']['delivery']['delivery_last_name']['#value'] = $retrieved['last_name'];
//$form['panes']['delivery']['delivery_zone']['#value'] = $retrieved['state_provice_name'];
}
}
}
}
Any ideas on populating country and state?




Joined: 10/06/2008