Instead of adding checkbox using hook_form_alter() you can use hook_commerce_...

Contribution Date
Technology
Contribution Project
Contribution Details

Instead of adding checkbox using hook_form_alter() you can use hook_commerce_checkout_pane_info() add new pane.
Then you can write submit handler and attach the value of checkbox in to order data so you can use it while redirecting.

Find code below : I hope this will help you out.

/**
* Implements hook_commerce_checkout_pane_info()
*/
function hook_commerce_checkout_pane_info() {
$panes['name_of_pane'] = array(
'title' => t('title'),
'page' => 'checkout',
'weight' => 10,
'base' => 'custom_pane',
);
return $panes;
}

/**
* Implements base_checkout_form()
*/
function custom_pane_checkout_form($form, $form_state, $checkout_pane, $order) {
$checkout_form ['checkbox'] = array (
'#type' => 'checkbox',
'#title' => t ( 'title ')
);
return $checkout_form;
}

/**
* Implements base_checkout_form_submit
*
* @param unknown $form
* @param unknown $form_state
* @param unknown $checkout_pane
* @param unknown $order
*/
function custom_pane_checkout_form_submit($form, &$form_state, $checkout_pane, $order) {
// save checkbox value into order
$pane_id = $checkout_pane ['pane_id'];
$checkbox_value = $form_state ['values'] ['name_of_pane'] ['checkbox'];
$order->data [$checkout_pane ['pane_id']] = $checkbox_value;
}

Contribution Author
Files count
0
Patches count
0