Skip to content

Instantly share code, notes, and snippets.

@carwin
Created September 7, 2012 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carwin/3668041 to your computer and use it in GitHub Desktop.
Save carwin/3668041 to your computer and use it in GitHub Desktop.
Drupal 7: (UNTESTED) Add an extra pane to Ubercart's checkout form / review.
<?php
function yourmodule_custom_form($form, &$form_state, $term) {
/* Note: rather than passing a $term var, you could use arg(2) from the url */
drupal_set_title('Your Label: ' . ucwords($term));
// or
drupal_set_title('Your Label: ' . str_replace('%20',' ', arg(2)));
/* Make life easier: */
$school = ucwords($term);
/*
* Amongst your other form items, create an
* unchangeable pre-populated text field.
*/
$form['school'] = array( // Sample "School" field.
'#type' => 'textfield',
'#title' => 'school', // should probably use t() but you don't have to.
'#disabled' => TRUE, // Now it's a form item that can't be changed.
'#required' => TRUE,
'#value' => $school,
)
return $form;
}
/*
* Add a whole pane to the checkout form,
* which should make things look pretty for your
* order review page too.
*
* Implements hook_checkout_pane()
*
*/
function yourmodule_uc_checkout_pane() {
$panes['school_pane'] = array(
'callback' => 'yourmodule_checkout_pane_school_pane', // Or whatever you wanna call it.
'title' => t('School'),
'desc' => t('Go Nixa Eagles! Branson Pirates suck!'), // Might put some useful non-specific school related stuf here.
'weight' => 42, // Douglas Adams.
'process' => FALSE, // I don't know if this pane needs to be processed
'collapsible' => FALSE,
);
return $panes;
}
/*
* Callback for yourmodule_uc_checkout_pane()
*/
function yourmodule_checkout_pane_school_pane($op, $order, $form, &$form_state) {
$school = $form_state['values']['school'];
switch($op) {
case 'view':
$contents = 'Your school is so great!';
$contents .= '<address>'. $school .'<br />';
$contents .= '555 Fake Address<br />Faketown, MO. 65714</address>';
case 'review'
$contents = 'Yo momma';
}
return $contents;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment