Okay, I'm just going to take a shut in the dark, in hopes someone will be able to point out my errors. Here is the code that right now is adding a pane:
Tournament Roster
Fields: Player Name, Position, Email Address
However, nothing is being written to the database:
Once this gets figured out, I need to repeat the three fields several times to allow for someone to enter their entire team. Advice?
/*******************************************************************************
* Hook Functions (Ubercart)
******************************************************************************/
/**
* Implementation of hook_checkout_pane().
*/
function uc_lead_checkout_pane() {
$panes[] = array(
'id' => 'lead',
'callback' => 'uc_checkout_pane_lead',
'title' => t('Tournament Roster'),
'desc' => t('Tournament roster is required upon registering for a tournament.'),
'weight' => 8,
);
return $panes;
}
/**
* Implementation of hook_order().
*/
function uc_lead_order($op, &$arg1, $arg2) {
switch ($op) {
// Save the lead to the database.
case 'save':
if (!empty($arg1->lead['name'])) {
db_query("UPDATE {uc_leads} SET lead_name = '%s', lead_position = '%s', lead_email = 's' "
."WHERE order_id = %d", $arg1->lead['name'],
$arg1->lead['position'], $arg1->lead['email'], $arg1->order_id);
if (db_affected_rows() == 0) {
db_query("INSERT INTO {uc_leads} (lead_id, order_id, lead_name, lead_position, lead_email) VALUES (%d, %d, '%s', '%s', '%s')",
db_next_id('{uc_leads}_lead_id'), $arg1->order_id,
$arg1->lead['name'], $arg1->lead['position'], $arg1->lead['email']);
}
}
break;
// Load the lead from the database.
case 'load':
$result = db_query("SELECT * FROM {uc_leads} WHERE order_id = %d", $arg1->order_id);
if ($data = db_fetch_object($result)) {
$arg1->lead['name'] = $data->lead_name;
$arg1->lead['position'] = $data->lead_position;
$arg1->lead['email'] = $data->lead_email;
}
break;
// Delete the lead from the database.
case 'delete':
db_query("DELETE FROM {uc_leads} WHERE order_id = %d", $arg1->order_id);
break;
}
}
/**
* Implementation of hook_order_pane().
*/
function uc_lead_order_pane() {
$panes[] = array(
'id' => 'lead',
'callback' => 'uc_order_pane_lead',
'title' => t('Tourname Roster'),
'desc' => t(''),
'class' => 'abs-left',
'weight' => 7,
'show' => array('view'),
);
return $panes;
}
/*******************************************************************************
* Callback Functions, Forms, and Tables
******************************************************************************/
function uc_checkout_pane_lead($op, &$arg1, $arg2) {
switch ($op) {
case 'view':
$description = t('Tournament roster is required upon registering for Pro Hockey Tournaments');
$contents['lead_name'] = array(
'#type' => 'textfield',
'#title' => t('Player Name'),
'#default_value' => $arg1->lead['name'],
);
$contents['lead_position'] = array(
'#type' => 'textfield',
'#title' => t('Position'),
'#default_value' => $arg1->lead['position'],
);
$contents['lead_email'] = array(
'#type' => 'textfield',
'#title' => t('Email'),
'#default_value' => $arg1->lead['email'],
);
return array('description' => $description, 'contents' => $contents);
case 'review':
{
$review[1] = array('title' => t('Roster'), $arg1->lead['name']);
$review[2] = array('title' => t('Position'), $arg1->lead['position']);
$review[3] = array('title' => t('Email'), $arg1->lead['email']);
}
return $review;
}
}
function uc_order_pane_lead($op, $arg1) {
switch ($op) {
case 'view':
if (empty($arg1->lead['name'])) {
$lead = t('None specified');
}
else {
$lead = $arg1->lead['name'];
}
return t('Roster: !lead', array('!lead' => $lead));
}
}



Joined: 01/13/2008