Adding extra submit handler for checkout pane

Hi all,

I have a checkout pane for customer billing information and I'm trying to add an additional validate + submit handler for it to allow me to verify the address via a 3rd party service. At the moment, I can do something like:

$checkout_panes['customer_profile_billing']['callbacks']['checkout_form_submit'] = 'mymodule_customer_profile_billing_form_submit';

This triggers the function defined, but seems to replace the original submit handler which means I lose my data when I hit the payment page.

I've tried appending my callback as per usual form_alter code, eg: $form['#submit'][] = 'myfunction'; but this doesn't work. I've also tried the same sort of thing to the continue button's submit array but then have issues dealing with the $order object.

What's the recommended approach here? The documentation in commerce_checkout.api.php is nice, but it only shows me how I can replace submit handlers... not build on them.

Any ideas greatly received.


Posted: Sep 24, 2012


joshmiller Josh Miller on September 24, 2012

Code sample from here... http://drupal.org/node/1054728#comment-5860154

function customsite_form_alter(&$form, &$form_state, $form_id) {
//watchdog("customsite",'customsite in form_alter %formvar', array('%formvar' => $form['#id']),); // prints the name of the form
switch($form_id) {
'name_of_the_form': //get the name of the form using the above dsm($form_id)
$form['#submit'][] = 'test_form_submit';

test_form_submit($form, &$form_state) {
watchdog("customsite",'Form handler array: %formvar', array('%formvar' => print_r($form,true)),); // prints the name of the form

1. Make sure to use watchdog() -- not drupal_set_message()
2. Check /admin/reports/dblog for the output