public function CommerceShippingExample::submit_form in Commerce Shipping 7
Submit form callback: adds additional elements to the checkout pane when this shipping method is selected.
Overrides CommerceShippingQuote::submit_form
File
- modules/
plugins/ quotes/ example_plugin/ CommerceShippingExample.class.php, line 21
Class
Code
public function submit_form($pane_values, $checkout_pane, $order = NULL) {
$form = parent::submit_form($pane_values, $checkout_pane, $order);
// Default to the order in the object's scope if none is explicitly passed in.
if (empty($order)) {
$order = $this->order;
}
// Merge values from the order into the checkout pane values.
if (!empty($order->data['commerce_shipping_example'])) {
$pane_values += $order->data['commerce_shipping_example'];
}
// Then merge in default values.
$pane_values += array(
'express' => 0,
'name' => '',
);
$form['express'] = array(
'#type' => 'checkbox',
'#title' => t('Express delivery'),
'#description' => t('Express delivery costs twice the normal amount.'),
'#default_value' => $pane_values['express'],
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#description' => t('This is a demonstration field coded to fail validation for single character values.'),
'#default_value' => $pane_values['name'],
'#required' => TRUE,
);
return $form;
}